|
12 | 12 |
|
13 | 13 | ######################################## |
14 | 14 |
|
15 | | -# Based on this recipe, adapted for Python 3, Git 2.8.x, and PEP-440 version identifiers |
16 | | -# http://blogs.nopcode.org/brainstorm/2013/05/20/pragmatic-python-versioning-via-setuptools-and-git-tags/ |
17 | | -# https://www.python.org/dev/peps/pep-0440/#version-scheme |
18 | | - |
19 | | -# Fetch version from git tags, and write to version.py. |
20 | | -# Also, when git is not available (PyPi package), use stored version.py. |
21 | 15 | version_py = path.join(path.dirname(__file__), 'zxing', 'version.py') |
22 | 16 |
|
23 | | -try: |
24 | | - version_git = sp.check_output(["git", "describe", "--tags", "--dirty=_dirty"]).strip().decode('ascii') |
25 | | - final, dev, blob, dirty = re.match(r'v?((?:\d+\.)*\d+)(?:-(\d+)-(g[a-z0-9]+))?(_dirty)?', version_git).groups() |
26 | | - version_pep = final+('.dev%s+%s'%(dev,blob) if dev else '')+(dirty if dirty else '') |
27 | | -except: |
28 | | - d = {} |
29 | | - with open(version_py, 'r') as fh: |
30 | | - exec(fh.read(), d) |
31 | | - version_pep = d['__version__'] |
32 | | -else: |
33 | | - with open(version_py, 'w') as fh: |
34 | | - print("# Do not edit this file, versioning is governed by git tags", file=fh) |
35 | | - print('__version__="%s"' % version_pep, file=fh) |
| 17 | +d = {} |
| 18 | +with open(version_py, 'r') as fh: |
| 19 | + exec(fh.read(), d) |
| 20 | + version_pep = d['__version__'] |
36 | 21 |
|
37 | 22 | ######################################## |
38 | 23 |
|
|
0 commit comments