Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
64 lines (56 loc) · 1.63 KB
/
Copy pathsetup.py
File metadata and controls
64 lines (56 loc) · 1.63 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
"""PhasorPy package Setuptools script."""
# project metadata are defined in pyproject.toml
import os
import sys
import sysconfig
import numpy
from setuptools import Extension, setup
DEBUG = bool(os.environ.get('PHASORPY_DEBUG', ''))
LIMITED_API = not sysconfig.get_config_var('Py_GIL_DISABLED')
print()
print(f'Building with numpy-{numpy.__version__}')
print()
if sys.platform == 'win32':
extra_compile_args = ['/openmp']
extra_link_args: list[str] = []
if DEBUG:
extra_compile_args += [
'/Zi',
'/Od',
'/DCYTHON_TRACE=1',
# '/DCYTHON_TRACE_NOGIL=1', # too slow
]
extra_link_args += ['-debug:full']
elif sys.platform == 'darwin':
# OpenMP not available in Xcode
# https://mac.r-project.org/openmp/
extra_compile_args = [] # ['-Xclang', '-fopenmp']
extra_link_args = [] # ['-lomp']
else:
extra_compile_args = ['-fopenmp']
extra_link_args = ['-fopenmp']
ext_modules = [
Extension(
'phasorpy._phasorpy',
['src/phasorpy/_phasorpy.pyx'],
include_dirs=[numpy.get_include()],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
define_macros=[
# ('CYTHON_TRACE_NOGIL', '1'),
('NPY_NO_DEPRECATED_API', 'NPY_2_0_API_VERSION'),
]
+ (
[('Py_LIMITED_API', 0x030C0000), ('CYTHON_LIMITED_API', '1')]
if LIMITED_API
else []
),
py_limited_api=LIMITED_API,
)
]
setup(
ext_modules=ext_modules,
options=(
{'bdist_wheel': {'py_limited_api': 'cp312'}} if LIMITED_API else {}
),
)