-
Notifications
You must be signed in to change notification settings - Fork 22
/
setup.py
47 lines (39 loc) · 1.9 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
from __future__ import print_function
import sys, os, re, subprocess as sp
from setuptools import setup
if sys.version_info < (3, 6):
sys.exit("Python 3.6 or newer is required.")
########################################
# Based on this recipe, adapted for Python 3, Git 2.8.x, and PEP-440 version identifiers
# http://blogs.nopcode.org/brainstorm/2013/05/20/pragmatic-python-versioning-via-setuptools-and-git-tags/
# https://www.python.org/dev/peps/pep-0440/#version-scheme
# Fetch version from git tags, and write to version.py.
# Also, when git is not available (PyPi package), use stored version.py.
version_py = os.path.join(os.path.dirname(__file__), 'tetherback', 'version.py')
try:
version_git = sp.check_output(["git", "describe", "--tags", "--dirty=_dirty"]).strip().decode('ascii')
final, dev, blob, dirty = re.match(r'v?((?:\d+\.)*\d+)(?:-(\d+)-(g[a-z0-9]+))?(_dirty)?', version_git).groups()
version_pep = final+('.dev%s+%s'%(dev,blob) if dev else '')+(dirty if dirty else '')
except:
d = {}
with open(version_py, 'r') as fh:
exec(fh.read(), d)
version_pep = d['__version__']
else:
with open(version_py, 'w') as fh:
print("# Do not edit this file, tetherback versioning is governed by git tags", file=fh)
print('__version__="%s"' % version_pep, file=fh)
########################################
setup(name="tetherback",
version=version_pep,
description=("Create backups of an Android device over USB (requires adb and TWRP recovery)"),
long_description=open('README.md').read(),
author="Daniel Lenski",
author_email="[email protected]",
install_requires=[ 'progressbar2>=3.6', 'tabulate' ],
license='GPL v3 or later',
url="https://github.com/dlenski/tetherback",
packages=["tetherback"],
entry_points={ 'console_scripts': [ 'tetherback=tetherback.__main__:main' ] }
)