forked from SimVascular/svZeroDSolver
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
38 lines (33 loc) · 1.57 KB
/
setup.py
File metadata and controls
38 lines (33 loc) · 1.57 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
import os
import shutil
from setuptools import setup
from cmake_setuptools import CMakeExtension, CMakeBuildExt
class CustomCMakeBuild(CMakeBuildExt):
def run(self):
# -------------------------------------------------
# 1. Build the C++ extension *without* the default
# setuptools copy step (set inplace False)
# -------------------------------------------------
inplace_orig = self.inplace # remember
self.inplace = False # inhibit copy_extensions_to_source
super().run() # runs CMake
self.inplace = inplace_orig # restore flag
# -------------------------------------------------
# 2. Locate the compiled library
# -------------------------------------------------
build_temp = os.path.abspath(self.build_temp)
search_root = os.path.join(build_temp, "python")
dest_dir = os.path.dirname(self.get_ext_fullpath("pysvzerod"))
for root, _, files in os.walk(search_root):
for f in files:
if f.startswith("pysvzerod") and f.endswith((".so", ".pyd", ".dll", ".dylib")):
src = os.path.join(root, f)
os.makedirs(dest_dir, exist_ok=True)
shutil.copy2(src, os.path.join(dest_dir, f))
print(f"[INFO] copied {src} -> {dest_dir}")
return
raise RuntimeError("pysvzerod binary not found in build tree")
setup(
ext_modules=[CMakeExtension("pysvzerod")],
cmdclass={"build_ext": CustomCMakeBuild},
)