Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
128 lines (106 loc) · 3.54 KB
/
Copy pathsetup.py
File metadata and controls
128 lines (106 loc) · 3.54 KB
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
import io
import os
import importlib.util
import platform
from setuptools import setup, find_packages, Command, Distribution
from wheel.bdist_wheel import bdist_wheel
#-- old setup.py workflow for backwards compatibility
#-- python setup.py build_external
#-- python setup.py install
NAME = "jigsawpy"
DESCRIPTION = \
"Python interface for the JIGSAW meshing library."
AUTHOR = "Darren Engwirda"
AUTHOR_EMAIL = "d.engwirda@gmail.com"
URL = "https://github.com/dengwirda/"
VERSION = "1.1.1"
REQUIRES_PYTHON = ">=3.6.0"
KEYWORDS = "Mesh-generation Delaunay Voronoi"
REQUIRED = [
"numpy", "scipy"
]
CLASSIFY = [
"Development Status :: 5 - Production/Stable",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: C++",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Scientific/Engineering :: Visualization"
]
HERE = os.path.abspath(os.path.dirname(__file__))
try:
with io.open(os.path.join(
HERE, "README.md"), encoding="utf-8") as f:
LONG_DESCRIPTION = "\n" + f.read()
except FileNotFoundError:
LONG_DESCRIPTION = DESCRIPTION
class build_external(Command):
description = "build external JIGSAW dependencies"
user_options = []
def initialize_options(self): pass
def finalize_options(self): pass
def run(self):
if (self.dry_run): return
spec = importlib.util.spec_from_file_location(
"jigsaw_build",
os.path.join(HERE, "build.py"))
build = importlib.util.module_from_spec (spec)
spec.loader.exec_module(build)
build.build_external()
class BinaryDistribution(Distribution):
def has_ext_modules(self):
return True
class build_wheel(bdist_wheel):
def run(self):
system = platform.system()
libraries = {
"Windows": "jigsaw.dll",
"Linux": "libjigsaw.so",
"Darwin": "libjigsaw.dylib",
}
if system not in libraries:
raise RuntimeError(
"Unsupported wheel platform: " + system)
suffix = ".exe" if system == "Windows" else ""
required = [
os.path.join(HERE, "jigsawpy", "_bin", name + suffix)
for name in ("jigsaw", "tripod", "marche")
]
required.append(os.path.join(
HERE, "jigsawpy", "_lib", libraries[system]))
missing = [
path for path in required if not os.path.isfile(path)
]
if missing:
raise RuntimeError(
"Missing JIGSAW backend binaries: " +
", ".join(missing) + ". Run python build.py "
"before building a wheel."
)
super().run()
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
author=AUTHOR,
author_email=AUTHOR_EMAIL,
python_requires=REQUIRES_PYTHON,
keywords=KEYWORDS,
url=URL,
packages=find_packages(exclude=["tests",]),
cmdclass={"build_external": build_external,
"bdist_wheel": build_wheel},
distclass=BinaryDistribution,
package_data={"jigsawpy": ["_bin/*", "_lib/*"]},
install_requires=REQUIRED,
extras_require={"netcdf": ["netCDF4"]},
classifiers=CLASSIFY
)