Exemplo n.º 1
0
 def get_python_file_version(self):
     setup_cfg = pypi.SetupConfig()
     if not setup_cfg.python_file_with_version():
         return
     lines = open(setup_cfg.python_file_with_version()).read().split('\n')
     for line in lines:
         match = UNDERSCORED_VERSION_PATTERN.search(line)
         if match:
             logger.debug("Matching __version__ line found: %r", line)
             line = line.lstrip('__version__').strip()
             line = line.lstrip('=').strip()
             line = line.replace('"', '').replace("'", "")
             return utils.strip_version(line)
Exemplo n.º 2
0
 def get_setup_py_version(self):
     if os.path.exists('setup.py'):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted version, like
         # UserWarnings.
         utils.system(utils.setup_py('egg_info'))
         version = utils.system(utils.setup_py('--version'))
         if version.startswith('Traceback'):
             # Likely cause is for example forgetting to 'import
             # os' when using 'os' in setup.py.
             logger.critical('The setup.py of this package has an error:')
             print(version)
             logger.critical('No version found.')
             sys.exit(1)
         return utils.strip_version(version)
Exemplo n.º 3
0
 def get_version_txt_version(self):
     version_file = self.filefind(['version.txt', 'version'])
     if version_file:
         f = open(version_file, 'r')
         version = f.read()
         return utils.strip_version(version)