forked from dhermes/bezier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
159 lines (133 loc) · 4.66 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
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Setup file for bezier."""
from __future__ import print_function
import os
import sys
import pkg_resources
import setuptools
import setup_helpers
import setup_helpers_macos
import setup_helpers_windows
VERSION = "0.10.1.dev1" # Also in ``codemeta.json`` and ``__init__.py``.
AUTHOR = "Danny Hermes" # Also in ``__init__.py``.
README_FILENAME = os.path.join(os.path.dirname(__file__), "README.rst")
NUMPY_MESSAGE = """\
Error: NumPy needs to be installed first. It can be installed via:
$ python -m pip install numpy
$ python3.7 -m pip install numpy
$ # OR
$ conda install numpy
"""
MISSING_F90_MESSAGE = """\
No Fortran 90 compiler found.
Skipping Fortran extension speedups.
"""
NO_EXTENSIONS_ENV = "BEZIER_NO_EXTENSIONS"
NO_SPEEDUPS_MESSAGE = """\
The {} environment variable has been used to explicitly disable the
building of extension modules.
""".format(
NO_EXTENSIONS_ENV
)
REQUIREMENTS = ("six >= 1.12.0",)
EXTRAS_REQUIRE = {
':implementation_name == "pypy"': ["numpy == 1.15.4"],
':implementation_name == "cpython"': ["numpy >= 1.17.0"],
}
DESCRIPTION = (
u"Helper for B\u00e9zier Curves, Triangles, and Higher Order Objects"
)
def is_installed(requirement):
try:
pkg_resources.require(requirement)
except pkg_resources.ResolutionError:
return False
else:
return True
def require_numpy():
if not is_installed("numpy>=1.9.0"):
print(NUMPY_MESSAGE, file=sys.stderr)
sys.exit(1)
def extension_modules():
if NO_EXTENSIONS_ENV in os.environ:
print(NO_SPEEDUPS_MESSAGE, file=sys.stderr)
return []
require_numpy()
if setup_helpers.BuildFortranThenExt.has_f90_compiler():
return setup_helpers.extension_modules()
else:
print(MISSING_F90_MESSAGE, file=sys.stderr)
return []
def make_readme():
with open(README_FILENAME, "r") as file_obj:
return file_obj.read()
def setup():
setuptools.setup(
name="bezier",
version=VERSION,
description=DESCRIPTION,
author=AUTHOR,
author_email="[email protected]",
long_description=make_readme(),
scripts=(),
url="https://github.com/dhermes/bezier",
project_urls={
"Documentation": "https://bezier.readthedocs.io/",
"Changelog": (
"https://bezier.readthedocs.io/en/latest/releases/index.html"
),
"Issue Tracker": "https://github.com/dhermes/bezier/issues",
},
keywords=["Geometry", "Curve", "Bezier", "Intersection", "Python"],
packages=["bezier"],
package_dir={"": os.path.join("src", "python")},
license="Apache 2.0",
platforms="Posix; macOS; Windows",
package_data={
"bezier": [
"*.pxd",
os.path.join("include", "*.h"),
os.path.join("include", "bezier", "*.h"),
os.path.join("lib", "*.a"),
os.path.join("lib", "*.lib"),
os.path.join("extra-dll", "*.dll"),
]
},
zip_safe=True,
install_requires=REQUIREMENTS,
extras_require=EXTRAS_REQUIRE,
ext_modules=extension_modules(),
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Mathematics",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
cmdclass={"build_ext": setup_helpers.BuildFortranThenExt},
)
def main():
# Add any "patches" needed for the Fortran compiler.
setup_helpers.BuildFortranThenExt.PATCH_FUNCTIONS[:] = [
setup_helpers.patch_f90_compiler,
setup_helpers_macos.patch_f90_compiler,
setup_helpers_windows.patch_f90_compiler,
]
setup_helpers_windows.patch_cmd(setup_helpers.BuildFortranThenExt)
setup()
if __name__ == "__main__":
main()