-
Notifications
You must be signed in to change notification settings - Fork 16
/
setup.py
76 lines (70 loc) · 2.15 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
67
68
69
70
71
72
73
74
75
76
"""Build the Srctools package."""
from setuptools import setup, Extension
import sys
import os
import setuptools
WIN = sys.platform.startswith('win')
MAC = sys.platform.startswith('darwin')
root = os.path.dirname(__file__)
print(f'Srctools, {WIN=}, {MAC=}, setuptools={getattr(setuptools, "__version__", "???")}')
# Mandatory in CI!
optional_ext = os.environ.get('CIBUILDWHEEL', '0') != '1'
if WIN:
openmp = ['/openmp']
openmp_link = []
elif MAC:
openmp = [] # Not supported by system Clang.
openmp_link = []
else:
openmp = ['-fopenmp']
openmp_link = ['-fopenmp']
extensions = [
Extension(
"srctools._tokenizer",
sources=["src/srctools/_tokenizer.pyx"],
optional=optional_ext,
extra_compile_args=[
# '/FAs', # MS ASM dump
],
),
Extension(
"srctools._cy_vtf_readwrite",
include_dirs=[os.path.abspath(os.path.join(root, "src", "libsquish"))],
language='c++',
optional=optional_ext,
sources=[
"src/srctools/_cy_vtf_readwrite.pyx",
"src/libsquish/alpha.cpp",
"src/libsquish/clusterfit.cpp",
"src/libsquish/colourblock.cpp",
"src/libsquish/colourfit.cpp",
"src/libsquish/colourset.cpp",
"src/libsquish/maths.cpp",
"src/libsquish/rangefit.cpp",
"src/libsquish/singlecolourfit.cpp",
"src/libsquish/squish.cpp",
],
extra_compile_args=[
# '/FAs', # MS ASM dump
*openmp,
],
extra_link_args=openmp_link,
),
Extension(
"srctools._math",
include_dirs=[os.path.abspath(os.path.join(root, "src", "quickhull/"))],
language='c++',
optional=optional_ext,
sources=["src/srctools/_math.pyx", "src/srctools/_math_matrix.cpp", "src/quickhull/QuickHull.cpp"],
extra_compile_args=[
# '/FAs', # MS ASM dump
] if WIN else [
'-std=c++11', # Needed for Mac to work
],
),
]
# Don't build extension modules for docs, they're not useful.
if 'READTHEDOCS' in os.environ:
setup()
else:
setup(ext_modules=extensions)