-
-
Notifications
You must be signed in to change notification settings - Fork 107
/
setup.py
120 lines (100 loc) · 3.31 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
import os
import sys
import warnings
from setuptools import setup, extension
from setuptools.command.build_ext import build_ext
setup_kwargs = {}
def error(*lines):
for line in lines:
print(line, file=sys.stderr)
try:
from stl import stl
if not hasattr(stl, 'BaseStl'):
error('ERROR',
'You have an incompatible stl package installed'
'Please run "pip uninstall -y stl" first')
sys.exit(1)
except ImportError:
pass
try:
import numpy
from Cython import Build
setup_kwargs['ext_modules'] = Build.cythonize([
extension.Extension(
'stl._speedups',
['stl/_speedups.pyx'],
include_dirs=[numpy.get_include()],
),
])
except ImportError:
error('WARNING',
'Cython and Numpy is required for building extension.',
'Falling back to pure Python implementation.')
# To prevent importing about and thereby breaking the coverage info we use this
# exec hack
about = {}
with open('stl/__about__.py') as fh:
exec(fh.read(), about)
if os.path.isfile('README.rst'):
with open('README.rst') as fh:
long_description = fh.read()
else:
long_description = 'See http://pypi.python.org/pypi/%s/' % (
about['__package_name__'])
install_requires = [
'numpy',
'python-utils>=3.4.5',
]
tests_require = ['pytest']
class BuildExt(build_ext):
def run(self):
try:
build_ext.run(self)
except Exception as e:
warnings.warn('''
Unable to build speedups module, defaulting to pure Python. Note
that the pure Python version is more than fast enough in most cases
%r
''' % e)
if __name__ == '__main__':
setup(
python_requires='>3.6.0',
name=about['__package_name__'],
version=about['__version__'],
author=about['__author__'],
author_email=about['__author_email__'],
description=about['__description__'],
url=about['__url__'],
license='BSD',
packages=['stl'],
package_data={about['__import_name__']: ['py.typed']},
long_description=long_description,
tests_require=tests_require,
entry_points={
'console_scripts': [
'stl = %s.main:main' % about['__import_name__'],
'stl2ascii = %s.main:to_ascii' % about['__import_name__'],
'stl2bin = %s.main:to_binary' % about['__import_name__'],
],
},
classifiers=[
'Development Status :: 6 - Mature',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Software Development :: Libraries :: Python Modules',
],
install_requires=install_requires,
cmdclass=dict(
build_ext=BuildExt,
),
**setup_kwargs
)