Skip to content

Commit

Permalink
Update noxfile.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Saswatsusmoy authored Oct 24, 2023
1 parent 28f0cc7 commit 17bc401
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def run_pybamm_requires(session):
"libsundials_nvecserial",
"libsundials_nvecopenmp"
]

KLU_LIBS = [
"libsuitesparseconfig",
"libklu",
Expand All @@ -61,38 +61,45 @@ def run_pybamm_requires(session):
]

if sys.platform == "linux":
fileext = ".so"
elif sys.platform == "darwin":
fileext = ".dylib"
sundials_so_path = [
Path(PYBAMM_ENV["LD_LIBRARY_PATH"], lib)
for lib in SUNDIALS_LIBS
]
klu_so_path = [
Path(PYBAMM_ENV["LD_LIBRARY_PATH"], lib)
for lib in KLU_LIBS
]

sundials_so_path = [
Path(PYBAMM_ENV["LD_LIBRARY_PATH"], lib + fileext)
for lib in SUNDIALS_LIBS
elif sys.platform == "darwin":
sundials_so_path = [
Path(PYBAMM_ENV["LD_LIBRARY_PATH"], lib + ".dylib")
for lib in SUNDIALS_LIBS
]

klu_so_path = [
Path(PYBAMM_ENV["LD_LIBRARY_PATH"], lib + fileext)
for lib in KLU_LIBS
klu_so_path = [
Path(PYBAMM_ENV["LD_LIBRARY_PATH"], lib + ".dylib")
for lib in KLU_LIBS
]

if sys.platform != "win32":
session.install("wget", "cmake", silent=False)

if all(path.exists() for path in sundials_so_path) and all(path.exists() for path in klu_so_path) and not force_rebuild:
if sundials_so_path != [] and klu_so_path != [] and not force_rebuild:
session.warn("Found existing build-time requirements, skipping installation. Note: run with the --force flag (nox -s pybamm-requires -- --force) to invoke re-installation.")
else:
session.run("python", "scripts/install_KLU_Sundials.py")
if os.path.exists("./pybind11"):
session.log("Found pybind11")
elif not os.path.exists("./pybind11"):
session.run(
"git",
"clone",
"https://github.com/pybind/pybind11.git",
"pybind11/",
external=True,
)
else:
session.error("nox -s pybamm-requires is only available on Linux & macOS.")

if os.path.exists("./pybind11"):
session.log("Found pybind11")
elif not os.path.exists("./pybind11"):
session.run(
"git",
"clone",
"https://github.com/pybind/pybind11.git",
"pybind11/",
external=True,
)
else:
session.error("nox -s pybamm-requires is only available on Linux & macOS.")


@nox.session(name="coverage")
Expand Down

0 comments on commit 17bc401

Please sign in to comment.