-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·105 lines (87 loc) · 3.2 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import io
from itertools import chain
import os
import shutil
import warnings
from setuptools import setup
pkg_name = 'sym'
url = 'https://github.com/bjodah/' + pkg_name
license = 'BSD'
SYM_RELEASE_VERSION = os.environ.get('SYM_RELEASE_VERSION', '') # v*
# https://conda.pydata.org/docs/build.html#environment-variables-set-during-the-build-process
if os.environ.get('CONDA_BUILD', '0') == '1':
try:
SYM_RELEASE_VERSION = 'v' + open(
'__conda_version__.txt', 'rt').readline().rstrip()
except IOError:
pass
def _path_under_setup(*args):
return os.path.join(os.path.dirname(__file__), *args)
release_py_path = _path_under_setup(pkg_name, '_release.py')
if len(SYM_RELEASE_VERSION) > 0:
if SYM_RELEASE_VERSION[0] == 'v':
TAGGED_RELEASE = True
__version__ = SYM_RELEASE_VERSION[1:]
else:
raise ValueError("Ill formated version")
else:
TAGGED_RELEASE = False
# read __version__ attribute from _release.py:
exec(open(release_py_path).read())
classifiers = [
"Development Status :: 3 - Alpha",
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
]
tests = [
'sym.tests',
]
with open(_path_under_setup(pkg_name, '__init__.py'), 'rt') as f:
short_description = f.read().split('"""')[1].split('\n')[1]
if not 10 < len(short_description) < 255:
warnings.warn("Short description from __init__.py proably not read correctly")
long_descr = io.open(_path_under_setup('README.rst'), encoding='utf-8').read()
if not len(long_descr) > 100:
warnings.warn("Long description from README.rst probably not read correctly.")
_author, _author_email = open(_path_under_setup('AUTHORS'), 'rt').readline().split('<')
extras_req = {
'symbolic': ['sympy>=1.0', 'pysym', 'symcxx>=0.1.10'], # use conda for symengine
'docs': ['Sphinx', 'sphinx_rtd_theme', 'numpydoc'],
'testing': ['pytest', 'pytest-cov', 'pytest-flakes', 'pytest-pep8']
}
if sys.version_info[0] > 2:
extras_req['symbolic'].append('diofant')
extras_req['all'] = list(chain(extras_req.values()))
setup_kwargs = dict(
name=pkg_name,
version=__version__,
description=short_description,
long_description=long_descr,
classifiers=classifiers,
author=_author,
author_email=_author_email.split('>')[0].strip(),
url=url,
license=license,
packages=[pkg_name] + tests,
install_requires=['numpy'],
extras_require=extras_req
)
if __name__ == '__main__':
try:
if TAGGED_RELEASE:
# Same commit should generate different sdist
# depending on tagged version (set $SYM_RELEASE_VERSION)
# e.g.: $ SYM_RELEASE_VERSION=v1.2.3 python setup.py sdist
# this will ensure source distributions contain the correct version
shutil.move(release_py_path, release_py_path+'__temp__')
open(release_py_path, 'wt').write(
"__version__ = '{}'\n".format(__version__))
setup(**setup_kwargs)
finally:
if TAGGED_RELEASE:
shutil.move(release_py_path+'__temp__', release_py_path)