Mercurial > evolve
diff setup.py @ 2049:b81d3775006b
evolve: move extension metadata in their own module
This will allow the server only extension to reuse them. As a side effect we can
now simplify the config parsing in setup.py
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 07 Mar 2017 13:24:07 +0100 |
parents | 2d9e7b936ee1 |
children | 05170e635e26 |
line wrap: on
line diff
--- a/setup.py Tue Mar 07 13:12:27 2017 +0100 +++ b/setup.py Tue Mar 07 13:24:07 2017 +0100 @@ -2,25 +2,21 @@ from distutils.core import setup from os.path import dirname, join -def get_version(relpath): - '''Read version info from a file without importing it''' - for line in open(join(dirname(__file__), relpath), 'rb'): - # Decode to a fail-safe string for PY3 - # (gives unicode object in PY2) - line = line.decode('utf8') - if '__version__' in line: - if "'" in line: - return line.split("'")[1] +META_PATH = 'hgext3rd/evolve/metadata.py' + +def get_metadata(): + meta = {} + fullpath = join(dirname(__file__), META_PATH) + execfile(fullpath, meta) + return meta -def min_hg_version(relpath): +def get_version(): '''Read version info from a file without importing it''' - for line in open(join(dirname(__file__), relpath), 'rb'): - # Decode to a fail-safe string for PY3 - # (gives unicode object in PY2) - line = line.decode('utf8') - if 'testedwith' in line: - if "'" in line: - return min(line.split("'")[1].split()) + return get_metadata()['__version__'] + +def min_hg_version(): + '''Read version info from a file without importing it''' + return get_metadata()['minimumhgversion'] py_modules = [ 'hgext3rd.evolve.serveronly', @@ -34,19 +30,16 @@ py_modules.append('hgext3rd.evolve.hack.inhibit') py_modules.append('hgext3rd.evolve.hack.directaccess') - -EVOLVE_PATH = 'hgext3rd/evolve/__init__.py' - requires = [] try: import mercurial mercurial.__all__ except ImportError: - requires.append('mercurial>=%s' % min_hg_version(EVOLVE_PATH)) + requires.append('mercurial>=%s' % min_hg_version()) setup( name='hg-evolve', - version=get_version(EVOLVE_PATH), + version=get_version(), author='Pierre-Yves David', maintainer='Pierre-Yves David', maintainer_email='pierre-yves.david@ens-lyon.org',