|
15 | 15 | import setuptools |
16 | 16 |
|
17 | 17 |
|
18 | | -PROBLEMATIC_COMMANDS = 'install', 'develop', 'easy_install', 'bdist_egg' |
19 | | - |
20 | | -if not os.path.isdir('setuptools_scm.egg-info'): |
21 | | - print(__doc__) |
22 | | - |
23 | | - if any(c in sys.argv for c in PROBLEMATIC_COMMANDS): |
24 | | - sys.exit('please run `python setup.py egg_info` first') |
25 | | - |
26 | | - |
27 | | -def _find_hackish_version(): |
| 18 | +def scm_config(): |
28 | 19 | here = os.path.dirname(os.path.abspath(__file__)) |
| 20 | + egg_info = os.path.join(here, 'setuptools_scm.egg-info') |
| 21 | + has_entrypoints = os.path.isdir(egg_info) |
| 22 | + |
29 | 23 | sys.path.insert(0, here) |
30 | 24 | from setuptools_scm.hacks import parse_pkginfo |
31 | | - from setuptools_scm import get_version |
32 | | - try: |
33 | | - return get_version( |
34 | | - root=here, parse=parse_pkginfo, |
35 | | - **scm_config()) |
36 | | - except IOError: |
37 | | - pass |
38 | | - |
39 | | - |
40 | | -def scm_config(): |
| 25 | + from setuptools_scm.git import parse as parse_git |
41 | 26 | from setuptools_scm.version import ( |
| 27 | + |
42 | 28 | guess_next_dev_version, |
43 | 29 | get_local_node_and_date, |
44 | 30 | ) |
45 | | - return dict( |
| 31 | + |
| 32 | + def parse(root): |
| 33 | + try: |
| 34 | + return parse_pkginfo(root) |
| 35 | + except IOError: |
| 36 | + return parse_git(root) |
| 37 | + |
| 38 | + config = dict( |
46 | 39 | version_scheme=guess_next_dev_version, |
47 | 40 | local_scheme=get_local_node_and_date, |
48 | 41 | ) |
49 | 42 |
|
| 43 | + if has_entrypoints: |
| 44 | + return dict(use_scm_version=config) |
| 45 | + else: |
| 46 | + from setuptools_scm import get_version |
| 47 | + return dict(version=get_version( |
| 48 | + root=here, parse=parse, **config)) |
| 49 | + |
50 | 50 |
|
51 | 51 | with open('README.rst') as fp: |
52 | 52 | long_description = fp.read() |
53 | 53 |
|
54 | | -found_version = _find_hackish_version() |
55 | 54 |
|
56 | 55 | arguments = dict( |
57 | 56 | name='setuptools_scm', |
58 | 57 | url='https://github.com/pypa/setuptools_scm/', |
59 | 58 | zip_safe=True, |
60 | | - version=found_version, |
61 | | - # pass here since entrypints are not yet registred |
62 | | - use_scm_version=found_version is None and scm_config, |
63 | 59 | author='Ronny Pfannschmidt', |
64 | 60 | |
65 | 61 | description=('the blessed package to manage your versions by scm tags'), |
@@ -116,4 +112,5 @@ def scm_config(): |
116 | 112 | ) |
117 | 113 |
|
118 | 114 | if __name__ == '__main__': |
| 115 | + arguments.update(scm_config()) |
119 | 116 | setuptools.setup(**arguments) |
0 commit comments