-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
65 lines (54 loc) · 1.79 KB
/
setup.py
File metadata and controls
65 lines (54 loc) · 1.79 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
"""
Setup script for GXML with C extensions.
Usage:
pip install -e . # Editable install with C extensions
pip install -e ".[dev]" # With dev dependencies
C extensions are built next to their Python source (standard approach):
- src/gxml/elements/solvers/_c_solvers.*.pyd
- src/gxml/profiling/_c_profile.*.pyd
- src/gxml/mathutils/_vec3.*.pyd
These .pyd/.so files are gitignored.
"""
from setuptools import setup, Extension
import numpy as np
import sys
import platform
def get_compiler_flags():
"""Get platform-specific compiler flags."""
if sys.platform == 'win32':
return ['/O2', '/fp:fast', '/GL'], ['/LTCG']
elif platform.system() == 'Darwin':
return ['-O3', '-ffast-math', '-flto'], ['-flto']
else:
return ['-O3', '-march=native', '-ffast-math', '-flto'], ['-flto']
def get_extensions():
"""Build Extension objects."""
compile_args, link_args = get_compiler_flags()
return [
# C Solvers (intersection, face, geometry)
Extension(
'gxml.elements.solvers._c_solvers',
sources=['src/gxml/elements/solvers/_c_solvers.c'],
include_dirs=[np.get_include()],
extra_compile_args=compile_args,
extra_link_args=link_args,
),
# C Profiler
Extension(
'gxml.profiling._c_profile',
sources=['src/gxml/profiling/_c_profile.c'],
extra_compile_args=compile_args,
extra_link_args=link_args,
),
# Vec3 math
Extension(
'gxml.mathutils._vec3',
sources=['src/gxml/mathutils/_vec3.c'],
extra_compile_args=compile_args,
extra_link_args=link_args,
),
]
setup(
ext_modules=get_extensions(),
package_dir={'': 'src'},
)