Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
149 lines (124 loc) · 3.96 KB
/
Copy pathsetup.py
File metadata and controls
149 lines (124 loc) · 3.96 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ importabsolute_import
from __future__ importprint_function
importio
fromglobimportglob
fromos.pathimportbasename
fromos.pathimportdirname
fromos.pathimportjoin
fromos.pathimportsplitext
importre
importsys
fromsetuptoolsimportfind_packages
fromsetuptoolsimportsetup
version='1.0.0'
#### Small hack to force using a plain version number if the option
#### --plain-version is passed to setup.py
USE_DEFAULT_VERSION=False
try:
sys.argv.remove('--use-default-version')
USE_DEFAULT_VERSION=True
exceptValueError:
pass
####
_sys_v0=sys.version_info[0]
py2=_sys_v0==2
py3=_sys_v0==3
defget_version(default=version, template='{tag}.{distance}.{commit}{dirty}',
use_default=USE_DEFAULT_VERSION):
"""
Return a version collected from git if possible or fall back to an
hard-coded default version otherwise. If `use_default` is True,
always use the default version.
"""
ifuse_default:
returndefault
try:
tag, distance, commit, dirty=get_git_version()
ifnotdistanceandnotdirty:
# we are from a clean Git tag: use tag
returntag
distance='post{}'.format(distance)
ifdirty:
time_stamp=get_time_stamp()
dirty='.dirty.'+get_time_stamp()
else:
dirty=''
returntemplate.format(**locals())
except:
# no git data: use default version
returndefault
defget_time_stamp():
"""
Return a numeric UTC time stamp without microseconds.
"""
fromdatetimeimportdatetime
return (datetime.isoformat(datetime.utcnow()).split('.')[0]
.replace('T', '').replace(':', '').replace('-', ''))
defget_git_version():
"""
Return version parts from Git or raise an exception.
"""
fromsubprocessimportcheck_output, STDOUT
# this may fail with exceptions
cmd='git', 'describe', '--tags', '--long', '--dirty',
version=check_output(cmd, stderr=STDOUT).strip()
dirty=version.endswith('-dirty')
tag, distance, commit=version.split('-')[:3]
# lower tag and strip V prefix in tags
tag=tag.lower().lstrip('v ').strip()
# strip leading g from git describe commit
commit=commit.lstrip('g').strip()
returntag, int(distance), commit, dirty
defread(*names, **kwargs):
returnio.open(
join(dirname(__file__), *names),
encoding=kwargs.get('encoding', 'utf8')
).read()
# Accept Python3, but only when running setup.py. Released wheels should be for
# Python 2 only until we completed the Python3 port
ifpy2:
python_requires='>=2.7,<3'
elifpy3:
python_requires='>=3.6'
else:
raiseException('Unsupported Python version.')
setup(
name='tracecode-toolkit',
version=get_version(),
license='Apache-2.0',
description='Utility for trace sources and binaries codebase builds and transforms.',
long_description=read('README.rst'),
author='nexB Inc.',
author_email='info@nexb.com',
url='https://github.com/nexb/tracecode-toolkit',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] forpathinglob('src/*.py')],
include_package_data=True,
zip_safe=False,
classifiers=[
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Topic :: Utilities',
],
keywords=[],
install_requires=[
'click',
'scancode-toolkit >= 3.0',
'unicodecsv',
],
entry_points={
'console_scripts': [
'tracecode=tracecode.cli:cli',
],
},
extras_require={
# eg: 'rst': ['docutils>=0.11'],
}
)