-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
42 lines (31 loc) · 966 Bytes
/
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
# SPDX-FileCopyrightText: 2024 Helmholtz-Zentrum hereon GmbH
#
# SPDX-License-Identifier: CC0-1.0
"""Setup script for the psy-ugrid package."""
import os
import versioneer
from setuptools import Extension, setup
_USE_CYTHON = os.getenv("USE_CYTHON", "").lower()
# use cython, when there is no c code or when it is specified via environment
# variable
USE_CYTHON = not os.path.exists(
os.path.join("psy_ugrid", "_create_dual_node_mesh.c")
) or (
bool(_USE_CYTHON)
and (not _USE_CYTHON.startswith("f") and not _USE_CYTHON.startswith("n"))
)
ext = ".pyx" if USE_CYTHON else ".c"
extensions = [
Extension(
"psy_ugrid._create_dual_node_mesh",
sources=[os.path.join("psy_ugrid", "_create_dual_node_mesh" + ext)],
)
]
if USE_CYTHON:
from Cython.Build import cythonize
extensions = cythonize(extensions)
setup(
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
ext_modules=extensions,
)