|
1 | | -#!/usr/bin/env python |
| 1 | +#!/usr/bin/env python3 |
2 | 2 |
|
| 3 | +from __future__ import print_function |
3 | 4 | import sys, os, re, subprocess as sp |
4 | | -from distutils.core import setup |
| 5 | +from setuptools import setup |
5 | 6 |
|
6 | 7 | if not sys.version_info[0] == 3: |
7 | 8 | sys.exit("Python 2.x is not supported; Python 3.x is required.") |
|
14 | 15 |
|
15 | 16 | # Fetch version from git tags, and write to version.py. |
16 | 17 | # Also, when git is not available (PyPi package), use stored version.py. |
17 | | -version_py = os.path.join(os.path.dirname(__file__), 'version.py') |
| 18 | +version_py = os.path.join(os.path.dirname(__file__), 'tetherback', 'version.py') |
18 | 19 |
|
19 | 20 | try: |
20 | | - version_git = sp.check_output(["git", "describe", "--tags"]).strip().decode('ascii') |
21 | | - final, dev, blob = re.match(r'v?((?:\d+\.)*\d+)(?:-(\d+)-(g[a-z0-9]+))?', version_git).groups() |
22 | | - version_pep = final+('.dev%s+%s'%(dev,blob) if dev else '') |
23 | | -except sp.CalledProcessError: |
| 21 | + version_git = sp.check_output(["git", "describe", "--tags", "--dirty=_dirty"]).strip().decode('ascii') |
| 22 | + final, dev, blob, dirty = re.match(r'v?((?:\d+\.)*\d+)(?:-(\d+)-(g[a-z0-9]+))?(_dirty)?', version_git).groups() |
| 23 | + version_pep = final+('.dev%s+%s'%(dev,blob) if dev else '')+(dirty if dirty else '') |
| 24 | +except: |
| 25 | + d = {} |
24 | 26 | with open(version_py, 'r') as fh: |
25 | | - version_pep = open(version_py).read().strip().split('=')[-1][1:-1] |
| 27 | + exec(fh.read(), d) |
| 28 | + version_pep = d['__version__'] |
26 | 29 | else: |
27 | 30 | with open(version_py, 'w') as fh: |
28 | 31 | print("# Do not edit this file, tetherback versioning is governed by git tags", file=fh) |
29 | | - print('__version__="%s"\n' % version_pep, file=fh) |
| 32 | + print('__version__="%s"' % version_pep, file=fh) |
30 | 33 |
|
31 | 34 | ######################################## |
32 | 35 |
|
|
0 commit comments