Skip to content

get_version when using archinstall as python module instead of from pacman #4244

@h8d13

Description

@h8d13
Traceback (most recent call last):                                                                                                                                   
    File "<frozen runpy>", line 198, in _run_module_as_main                                                                                                            
    File "<frozen runpy>", line 88, in _run_code                                                                                                                           
    File "/home/root/archinstoo/archinstall/__main__.py", line 3, in <module>                                                                                  
      from archinstall.main import main                                                                                                                                    
    File "/home/root/archinstoo/archinstall/main.py", line 11, in <module>                                                                                       
      from archinstall.lib.args import arch_config_handler                                                                                                             
    File "/home/root/archinstoo/archinstall/lib/args.py", line 560, in <module>                                                                              
      arch_config_handler: ArchConfigHandler = ArchConfigHandler()                                                                                                     
                                               ~~~~~~~~~~~~~~~~~^^                                                                                                     
    File "/home/root/archinstoo/archinstall/lib/args.py", line 258, in __init__                                                                              
      self._parser: ArgumentParser = self._define_arguments()                                                                                                          
                                     ~~~~~~~~~~~~~~~~~~~~~~^^                                                                                                          
    File "/home/root/archinstoo/archinstall/lib/args.py", line 304, in _define_arguments                                                                     
      version='%(prog)s ' + self._get_version(),                                                                                                                       
              ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~                                                                                                                        
  TypeError: can only concatenate str (not "NoneType") to str   

So from the read me we now promote this way of using it but it we also enforce this

	def _get_version(self) -> str:
		try:
			return version('archinstall')
		except Exception:
			return 'Archinstall version not found'

Which for obvious reasons would not exist since user used the git clone method (example on tarballs or minimal ISOs or from existing system).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions