Skip to content

Commit 891dc30

Browse files
committed
fix build.py
1 parent ea53587 commit 891dc30

1 file changed

Lines changed: 16 additions & 51 deletions

File tree

build.py

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
import os
66
import sys
77
import setuptools
8-
import numpy
98

10-
# rest of setup code here
11-
from setuptools import Extension, Distribution
12-
from setuptools.command.build_ext import build_ext
13-
14-
from Cython.Build import cythonize
159
# Detect platform
1610
system = platform.system()
1711
machine = platform.machine()
@@ -24,7 +18,6 @@
2418
extra_link_args = []
2519

2620
if system == 'Linux':
27-
# Ubuntu/Debian typical paths
2821
include_dirs.extend([
2922
'/usr/include',
3023
'/usr/include/eigen3',
@@ -40,12 +33,10 @@
4033
extra_link_args.append('-std=c++17')
4134

4235
elif system == 'Darwin': # macOS
43-
if machine == 'arm64': # Apple Silicon
44-
# Homebrew on Apple Silicon uses /opt/homebrew
36+
if machine == 'arm64':
4537
homebrew_prefix = '/opt/homebrew'
46-
else: # Intel Mac
38+
else:
4739
homebrew_prefix = '/usr/local'
48-
4940
include_dirs.extend([
5041
f'{homebrew_prefix}/include',
5142
f'{homebrew_prefix}/include/eigen3',
@@ -56,30 +47,20 @@
5647
f'{homebrew_prefix}/lib',
5748
'/usr/local/lib'
5849
])
59-
extra_compile_args.extend(['-std=c++17', '-stdlib=libc++',"-mcpu=apple-m1",'-flto'])
60-
extra_link_args.extend(['-std=c++17', '-stdlib=libc++','-flto'])
61-
62-
# On macOS, we might need to add rpath for finding libraries at runtime
63-
#extra_link_args.extend([
64-
# f'-Wl,-rpath,{homebrew_prefix}/lib',
65-
# '-Wl,-rpath,/usr/local/lib'
66-
#])
50+
extra_compile_args.extend(['-std=c++17', '-stdlib=libc++', '-mcpu=apple-m1', '-flto'])
51+
extra_link_args.extend(['-std=c++17', '-stdlib=libc++', '-flto'])
6752

6853
elif system == 'Windows':
69-
# Windows paths - adjust based on your CGAL installation
70-
# Common locations for vcpkg or manual installation
7154
vcpkg_root = os.environ.get('VCPKG_ROOT', 'C:/vcpkg')
7255
cgal_root = os.environ.get('CGAL_DIR', 'C:/CGAL')
73-
7456
include_dirs.extend([
7557
f'{vcpkg_root}/installed/x64-windows/include',
7658
f'{cgal_root}/include',
7759
f'{cgal_root}/auxiliary/gmp/include',
78-
'C:/boost/include', # Boost is often required
60+
'C:/boost/include',
7961
'C:/Program Files/CGAL/include',
8062
'C:/local/include'
8163
])
82-
8364
library_dirs.extend([
8465
f'{vcpkg_root}/installed/x64-windows/lib',
8566
f'{cgal_root}/lib',
@@ -88,34 +69,26 @@
8869
'C:/Program Files/CGAL/lib',
8970
'C:/local/lib'
9071
])
91-
92-
# Windows uses different library names
93-
libraries = ['gmp-10', 'mpfr-4'] # Might need to adjust version numbers
94-
95-
# MSVC compiler flags
72+
# Use the unversioned library names provided by vcpkg
73+
libraries = ['gmp', 'mpfr']
9674
extra_compile_args = ['/OX', '/std:c++17', '/EHsc']
9775
extra_link_args = []
98-
99-
# Add Windows-specific defines
10076
extra_compile_args.extend([
10177
'/D_USE_MATH_DEFINES',
102-
'/DNOMINMAX', # Prevent Windows.h from defining min/max macros
78+
'/DNOMINMAX',
10379
'/DCGAL_DISABLE_ROUNDING_MATH_CHECK'
10480
])
10581

106-
# Allow environment variables to override paths
107-
if 'CGAL_INCLUDE_DIR' in os.environ:
108-
include_dirs.insert(0, os.environ['CGAL_INCLUDE_DIR'])
109-
if 'CGAL_LIBRARY_DIR' in os.environ:
110-
library_dirs.insert(0, os.environ['CGAL_LIBRARY_DIR'])
111-
if 'EIGEN3_INCLUDE_DIR' in os.environ:
112-
include_dirs.insert(0, os.environ['EIGEN3_INCLUDE_DIR'])
82+
# Allow environment overrides
83+
for var, lst in [('CGAL_INCLUDE_DIR', include_dirs), ('CGAL_LIBRARY_DIR', library_dirs), ('EIGEN3_INCLUDE_DIR', include_dirs)]:
84+
if var in os.environ:
85+
lst.insert(0, os.environ[var])
11386

11487
# Filter out non-existent directories
11588
include_dirs = [d for d in include_dirs if os.path.exists(d)]
11689
library_dirs = [d for d in library_dirs if os.path.exists(d)]
11790

118-
# Print detected configuration for debugging
91+
# Debug output
11992
logo = rf"""
12093
{platform.uname()}
12194
compile_args: {extra_compile_args}
@@ -126,7 +99,6 @@
12699
print(f"Library directories: {library_dirs}")
127100
print(f"Libraries: {libraries}")
128101

129-
130102
extensions = [
131103
Extension(
132104
"cgal_alpha_wrapping._cgal_alpha_wrapping",
@@ -141,8 +113,6 @@
141113
)
142114
]
143115

144-
145-
146116
compiler_directives = dict(
147117
boundscheck=False,
148118
wraparound=False,
@@ -155,7 +125,6 @@
155125
)
156126

157127
def get_version():
158-
"""Get version from environment variable or default."""
159128
return os.environ.get('CGAL_ALPHA_WRAPPING_VERSION', '0.1.0')
160129

161130
if __name__ == "__main__":
@@ -165,10 +134,7 @@ def get_version():
165134
nthreads=os.cpu_count(),
166135
include_path=[np.get_include()],
167136
compiler_directives=compiler_directives
168-
169137
)
170-
171-
# Set up distribution with dynamic version
172138
version = get_version()
173139
dist = Distribution({
174140
"ext_modules": ext_modules,
@@ -179,8 +145,7 @@ def get_version():
179145
cmd.ensure_finalized()
180146
cmd.run()
181147

182-
import os, shutil
183-
148+
import shutil
184149
for output in cmd.get_outputs():
185-
relative_extension = os.path.relpath(output, cmd.build_lib)
186-
shutil.copyfile(output, relative_extension)
150+
rel = os.path.relpath(output, cmd.build_lib)
151+
shutil.copyfile(output, rel)

0 commit comments

Comments
 (0)