-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
66 lines (51 loc) · 1.69 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
# This file is part of the shxarray software which is licensed
# under the Apache License version 2.0 (see the LICENSE file in the main repository)
# Copyright Roelof Rietbroek ([email protected]), 2023
#
from setuptools import setup,Extension
from setuptools_scm import get_version
from Cython.Build import cythonize
import Cython.Compiler.Options
from packaging.version import Version
import os
import numpy as np
import sys
if sys.platform.startswith("win"):
winplatform=True
extra_args = ['/openmp']
else:
winplatform=False
extra_args = ['-fopenmp']
if "DEBUG_CYTHON" in os.environ:
debug=True
extra_args.append('-O0')
#extra_args.append('-pg')
else:
debug=False
#don't necessarily use cython
if "USE_CYTHON" in os.environ or winplatform:
# note being on windows forces the use of cython
useCython=True
ext=".pyx"
Cython.Compiler.Options.annotate = True
else:
useCython=False
ext=".cpp"
#Force the use of cython if numpy has a version < 2
if not useCython and Version(np.__version__) < Version ("2.0.0"):
useCython=True
ext=".pyx"
def listexts():
names=["shlib"]
exts=[]
for nm in names:
exts.append(Extension("shxarray."+nm.replace("/","."),["src/builtin_backend/"+nm+ext],include_dirs=[np.get_include(),"."], define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],extra_compile_args=extra_args,extra_link_args=extra_args))
return exts
extensions=listexts()
if useCython:
#additionally cythonize pyx files before building
extensions=cythonize(extensions,language_level=3,annotate=True,gdb_debug=debug)
setup(
version = get_version(root='.', relative_to=__file__),
ext_modules=extensions
)