Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
65 lines (50 loc) · 1.78 KB
/
Copy pathsetup.py
File metadata and controls
65 lines (50 loc) · 1.78 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
# Some things are not yet in pyproject.toml. They're here.
import sys
from setuptools import find_packages, setup
from setuptools.extension import Extension
try:
from Cython.Build import cythonize
except ImportError:
raise RuntimeError(
"Cython required for running the package installation\n"
+ "Try installing it with:\n"
+ "$> pip install cython"
)
try:
import numpy
except ImportError:
raise RuntimeError(
"Numpy required for running the package installation\n"
+ "Try installing it with:\n"
+ "$> pip install numpy"
)
# Define common arguments used to compile the extensions
common_link_args = ["-fopenmp"]
common_compile_args = ["-fopenmp", "-O3", "-ffast-math"]
common_include = [numpy.get_include()]
if sys.platform.startswith("darwin"):
common_link_args.append("-Wl,-rpath,/usr/local/opt/gcc/lib/gcc/9/")
extensions_data = {
"pysteps.motion._proesmans": {"sources": ["pysteps/motion/_proesmans.pyx"]},
"pysteps.motion._vet": {"sources": ["pysteps/motion/_vet.pyx"]},
}
extensions = []
for name, data in extensions_data.items():
include = data.get("include", common_include)
extra_compile_args = data.get("extra_compile_args", common_compile_args)
extra_link_args = data.get("extra_link_args", common_link_args)
pysteps_extension = Extension(
name,
sources=data["sources"],
depends=data.get("depends", []),
include_dirs=include,
language=data.get("language", "c"),
define_macros=data.get("macros", []),
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
)
extensions.append(pysteps_extension)
external_modules = cythonize(extensions, force=True, language_level=3)
setup(
ext_modules=external_modules,
)