Skip to content

Commit c88c1bb

Browse files
committed
adding correct build information for 0d solver
1 parent 09036b8 commit c88c1bb

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

setup.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def build_0d(num_cores=None):
301301
if shutil.which("cmake") is None:
302302
raise RuntimeError("CMake is not installed or not on the PATH.")
303303

304-
download_url_0d = "https://github.com/SimVascular/svZeroDSolver/archive/refs/tags/v2.0.tar.gz"
304+
download_url_0d = "https://github.com/SimVascular/svZeroDSolver/archive/refs/tags/v3.0.tar.gz"
305305
tarball_path_0d = "svZeroDSolver.tar.gz"
306306
source_path_0d = os.path.abspath("svZeroDSolver")
307307

@@ -323,26 +323,71 @@ def build_0d(num_cores=None):
323323
raise RuntimeError("Error extracting solver archives.") from e
324324

325325
build_dir_0d = os.path.abspath("tmp/solver-0d")
326+
os.makedirs(build_dir_0d, exist_ok=True)
326327

328+
# On Windows, pick a Visual Studio generator if possible
329+
if platform.system().lower().startswith("win"):
330+
vs_generator = pick_visual_studio_generator()
331+
if vs_generator:
332+
cmake_cmd += ["-G", vs_generator]
333+
else:
334+
print("No suitable Visual Studio found, falling back to default generator or NMake.")
335+
# cmake_cmd += ["-G", "NMake Makefiles"] # optional fallback
327336
# Add standard arguments
328337
cmake_cmd += [
329338
"-DCMAKE_BUILD_TYPE=Release",
330339
"-B", build_dir_0d,
331-
"-S", source_path_0d
340+
"-S", source_path_0d+os.sep+"svZeroDSolver-3.0"
332341
]
333342

343+
# Run configure step
344+
print("Configuring mmg with CMake:", " ".join(cmake_cmd))
345+
try:
346+
subprocess.check_call(cmake_cmd)
347+
except subprocess.CalledProcessError as e:
348+
raise RuntimeError("CMake configure failed for mmg.") from e
349+
334350
# Run build step
335351
build_cmd = [
336352
"cmake",
337353
"--build", build_dir_0d,
338354
"--parallel", str(num_cores)
339355
]
356+
357+
if platform.system().lower().startswith("win"):
358+
# or detect if vs_generator is set if you want to be more precise
359+
build_cmd += ["--config", "Release"]
360+
361+
try:
362+
subprocess.check_call(build_cmd)
363+
except subprocess.CalledProcessError as e:
364+
raise RuntimeError("CMake build failed for svZeroDSolver.") from e
365+
366+
install_tmp_prefix = os.path.join("svv", "tmp")
367+
os.makedirs(install_tmp_prefix, exist_ok=True)
368+
install_cmd = [
369+
"cmake",
370+
"--install", build_dir_0d,
371+
"--prefix", os.path.abspath(install_tmp_prefix),
372+
]
373+
374+
# For multi-configuration generators on Windows (like Visual Studio),
375+
# specify `--config Release` explicitly if you built in Release mode.
376+
if platform.system().lower().startswith("win"):
377+
install_cmd += ["--config", "Release"]
378+
379+
print("Installing svZeroDSolver with CMake:", " ".join(install_cmd))
380+
subprocess.check_call(install_cmd)
381+
print(f"svZeroDSolver executables have been installed into: {install_tmp_prefix}")
382+
383+
340384
class DownloadAndBuildExt(build_ext):
341385
def run(self):
342386
#------------------------------
343387
# Get MMG Remeshing Source Code
344388
#------------------------------
345389
build_mmg()
390+
build_0d()
346391
# -----------------------------
347392
# 1. Download: handle errors
348393
# -----------------------------

0 commit comments

Comments
 (0)