1 import os |
1 import os |
2 from distutils.core import setup |
2 from distutils.core import setup |
3 from os.path import dirname, join |
3 from os.path import dirname, join |
4 |
4 |
5 def get_version(relpath): |
5 META_PATH = 'hgext3rd/evolve/metadata.py' |
|
6 |
|
7 def get_metadata(): |
|
8 meta = {} |
|
9 fullpath = join(dirname(__file__), META_PATH) |
|
10 execfile(fullpath, meta) |
|
11 return meta |
|
12 |
|
13 def get_version(): |
6 '''Read version info from a file without importing it''' |
14 '''Read version info from a file without importing it''' |
7 for line in open(join(dirname(__file__), relpath), 'rb'): |
15 return get_metadata()['__version__'] |
8 # Decode to a fail-safe string for PY3 |
|
9 # (gives unicode object in PY2) |
|
10 line = line.decode('utf8') |
|
11 if '__version__' in line: |
|
12 if "'" in line: |
|
13 return line.split("'")[1] |
|
14 |
16 |
15 def min_hg_version(relpath): |
17 def min_hg_version(): |
16 '''Read version info from a file without importing it''' |
18 '''Read version info from a file without importing it''' |
17 for line in open(join(dirname(__file__), relpath), 'rb'): |
19 return get_metadata()['minimumhgversion'] |
18 # Decode to a fail-safe string for PY3 |
|
19 # (gives unicode object in PY2) |
|
20 line = line.decode('utf8') |
|
21 if 'testedwith' in line: |
|
22 if "'" in line: |
|
23 return min(line.split("'")[1].split()) |
|
24 |
20 |
25 py_modules = [ |
21 py_modules = [ |
26 'hgext3rd.evolve.serveronly', |
22 'hgext3rd.evolve.serveronly', |
27 ] |
23 ] |
28 py_packages = [ |
24 py_packages = [ |
32 |
28 |
33 if os.environ.get('INCLUDE_INHIBIT'): |
29 if os.environ.get('INCLUDE_INHIBIT'): |
34 py_modules.append('hgext3rd.evolve.hack.inhibit') |
30 py_modules.append('hgext3rd.evolve.hack.inhibit') |
35 py_modules.append('hgext3rd.evolve.hack.directaccess') |
31 py_modules.append('hgext3rd.evolve.hack.directaccess') |
36 |
32 |
37 |
|
38 EVOLVE_PATH = 'hgext3rd/evolve/__init__.py' |
|
39 |
|
40 requires = [] |
33 requires = [] |
41 try: |
34 try: |
42 import mercurial |
35 import mercurial |
43 mercurial.__all__ |
36 mercurial.__all__ |
44 except ImportError: |
37 except ImportError: |
45 requires.append('mercurial>=%s' % min_hg_version(EVOLVE_PATH)) |
38 requires.append('mercurial>=%s' % min_hg_version()) |
46 |
39 |
47 setup( |
40 setup( |
48 name='hg-evolve', |
41 name='hg-evolve', |
49 version=get_version(EVOLVE_PATH), |
42 version=get_version(), |
50 author='Pierre-Yves David', |
43 author='Pierre-Yves David', |
51 maintainer='Pierre-Yves David', |
44 maintainer='Pierre-Yves David', |
52 maintainer_email='pierre-yves.david@ens-lyon.org', |
45 maintainer_email='pierre-yves.david@ens-lyon.org', |
53 url='https://www.mercurial-scm.org/doc/evolution/', |
46 url='https://www.mercurial-scm.org/doc/evolution/', |
54 description='Flexible evolution of Mercurial history.', |
47 description='Flexible evolution of Mercurial history.', |