Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Implement Automatic Activation of Virtual Environment in the dev nox session #3408

Merged
10 changes: 9 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import nox
import os
import sys
from pathlib import Path


# Options to modify nox behaviour
Expand All @@ -16,6 +17,7 @@
"SUNDIALS_INST": f"{homedir}/.local",
"LD_LIBRARY_PATH": f"{homedir}/.local/lib:",
}
VENV_DIR = Path('./venv').resolve()


def set_environment_variables(env_dict, session):
Expand Down Expand Up @@ -117,8 +119,14 @@ def set_dev(session):
"""Install PyBaMM in editable mode."""
set_environment_variables(PYBAMM_ENV, session=session)
envbindir = session.bin
session.install("-e", ".[all]", silent=False)
session.install("virtualenv")
session.run("virtualenv", os.fsdecode(VENV_DIR), silent=True)
python = os.fsdecode(VENV_DIR.joinpath("bin/python"))
session.run(python, "-m", "pip", "install", "-e", ".[all]", silent=False)
akhilender-bongirwar marked this conversation as resolved.
Show resolved Hide resolved
session.install("cmake", silent=False)
session.install("-e", ".[dev]", external=True)
akhilender-bongirwar marked this conversation as resolved.
Show resolved Hide resolved
if session.platform.startswith("macos") or session.platform.startswith("linux"):
akhilender-bongirwar marked this conversation as resolved.
Show resolved Hide resolved
session.run(python, "-m", "pip", "install", ".[jax,odes]", silent=False)
akhilender-bongirwar marked this conversation as resolved.
Show resolved Hide resolved
if sys.platform == "linux" or sys.platform == "darwin":
akhilender-bongirwar marked this conversation as resolved.
Show resolved Hide resolved
session.run(
akhilender-bongirwar marked this conversation as resolved.
Show resolved Hide resolved
"echo",
Expand Down