forked from valbendan/pycflow2dot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·103 lines (95 loc) · 3.1 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
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
"""Installation script."""
from setuptools import setup
from pkg_resources import parse_version
name = 'pycflow2dot'
description = (
'Create C call graphs from multiple source files '
'using Cflow, producing linked PDF.')
long_description = open('README.md').read()
url = 'https://github.com/johnyf/{name}'.format(name=name)
VERSION_FILE = '{name}/_version.py'.format(name=name)
MAJOR = 0
MINOR = 2
MICRO = 4
VERSION = '{major}.{minor}.{micro}'.format(
major=MAJOR, minor=MINOR, micro=MICRO)
VERSION_TEXT = (
'# This file was generated from setup.py\n'
"version = '{version}'\n")
install_requires = [
'networkx >= 2.0',
'pydot >= 1.2.3']
tests_require = ['nose >= 1.3.4']
classifiers = [
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
('License :: OSI Approved :: '
'GNU General Public License v3 or later (GPLv3+)'),
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Software Development']
keywords = [
'c', 'call graph', 'control flow', 'dot',
'latex', 'cflow']
def git_version(version):
"""Return version with local version identifier."""
import git
repo = git.Repo('.git')
repo.git.status()
# assert versions are increasing
latest_tag = repo.git.describe(
match='v[0-9]*', tags=True, abbrev=0)
assert parse_version(latest_tag) <= parse_version(version), (
latest_tag, version)
sha = repo.head.commit.hexsha
if repo.is_dirty():
return '{v}.dev0+{sha}.dirty'.format(
v=version, sha=sha)
# commit is clean
# is it release of `version` ?
try:
tag = repo.git.describe(
match='v[0-9]*', exact_match=True,
tags=True, dirty=True)
except git.GitCommandError:
return '{v}.dev0+{sha}'.format(
v=version, sha=sha)
assert tag == 'v' + version, (tag, version)
return version
def run_setup():
# version
try:
version = git_version(VERSION)
except:
print('No git info: Assume release.')
version = VERSION
s = VERSION_TEXT.format(version=version)
with open(VERSION_FILE, 'w') as f:
f.write(s)
setup(
name=name,
version=version,
description=description,
long_description=long_description,
long_description_content_type='text/markdown',
author='Ioannis Filippidis',
author_email='jfilippidis@gmail.com',
url=url,
license='GPLv3',
install_requires=install_requires,
tests_require=tests_require,
packages=[name],
package_dir={name: name},
entry_points={
'console_scripts': ['cflow2dot = pycflow2dot.pycflow2dot:main']},
classifiers=classifiers,
keywords=keywords)
if __name__ == '__main__':
run_setup()