forked from tulip-control/dd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
166 lines (154 loc) · 5.23 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
"""Installation script."""
import argparse
import logging
import sys
from setuptools import setup
from pkg_resources import parse_version
import download
# inline:
# from dd import _parser, dddmp
# import git
name = 'dd'
description = (
'Binary decision diagrams implemented in pure Python, '
'as well as Cython wrappers of CUDD, Sylvan, and BuDDy.')
long_description = (
'dd is a package for working with binary decision diagrams '
'that includes both a pure Python implementation and '
'Cython bindings to C libraries (CUDD, Sylvan, BuDDy). '
'The Python and Cython modules implement the same API, '
'so the same user code runs with both. '
'All the standard operations on BDDs are available, '
'including dynamic variable reordering using sifting, '
'garbage collection, dump/load from files, plotting, '
'and a parser of quantified Boolean expressions. '
'More details can be found in the README at: '
'https://github.com/johnyf/dd')
url = 'https://github.com/johnyf/{name}'.format(name=name)
VERSION_FILE = '{name}/_version.py'.format(name=name)
MAJOR = 0
MINOR = 5
MICRO = 5
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 = [
'astutils >= 0.0.1',
'networkx >= 1.9.1',
'ply >= 3.4, <= 3.10',
'psutil >= 3.2.2',
'pydot >= 1.2.2',
'setuptools >= 19.6']
tests_require = [
'nose >= 1.3.4']
classifiers = [
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Cython',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Topic :: Scientific/Engineering',
'Topic :: Software Development']
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 parse_args():
"""Return `args` irrelevant to `setuptools`."""
parser = argparse.ArgumentParser()
parser.add_argument(
'--fetch', action='store_true',
help='download cudd from its website')
parser.add_argument(
'--linetrace', action='store_true',
help='use line tracing for Cython extensions')
for opt in download.EXTENSIONS:
parser.add_argument(
'--{s}'.format(s=opt), default=None,
const='', type=str, nargs='?',
help='build Cython extension {s}'.format(s=opt))
args, unknown = parser.parse_known_args()
args.sdist = 'sdist' in unknown
args.bdist_wheel = 'bdist_wheel' in unknown
# avoid confusing `setuptools`
sys.argv = [sys.argv[0]] + unknown
return args
def run_setup():
"""Build parser, get version from `git`, install."""
args = parse_args()
if args.fetch:
download.fetch_cudd()
# build extensions ?
ext_modules = download.extensions(args)
# version
try:
version = git_version(VERSION)
except AssertionError:
raise
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)
# build parsers
try:
from dd import _parser, dddmp
logging.getLogger('astutils').setLevel('ERROR')
dddmp._rewrite_tables(outputdir=name)
_parser._rewrite_tables(outputdir=name)
except ImportError:
print('WARNING: `dd` could not cache parser tables '
'(ignore this if running only for "egg_info").')
setup(
name=name,
version=version,
description=description,
long_description=long_description,
author='Ioannis Filippidis',
author_email='[email protected]',
url=url,
license='BSD',
install_requires=install_requires,
tests_require=tests_require,
packages=[name],
package_dir={name: name},
include_package_data=True,
ext_modules=ext_modules,
classifiers=classifiers,
keywords=[
'bdd', 'binary decision diagram', 'decision diagram',
'boolean', 'networkx', 'dot'])
if __name__ == '__main__':
run_setup()