diff --git a/docs/source/user_guide/installation/install-from-source.rst b/docs/source/user_guide/installation/install-from-source.rst index 0aa50cf8a8..fb448950bf 100644 --- a/docs/source/user_guide/installation/install-from-source.rst +++ b/docs/source/user_guide/installation/install-from-source.rst @@ -116,7 +116,7 @@ Using Nox (recommended) .. note:: It is recommended to use ``--verbose`` or ``-v`` to see outputs of all commands run. -This creates a virtual environment ``.nox/dev`` inside the ``PyBaMM/`` directory. +This creates a virtual environment ``venv/`` inside the ``PyBaMM/`` directory. It comes ready with PyBaMM and some useful development tools like `pre-commit `_ and `ruff `_. You can now activate the environment with @@ -125,13 +125,13 @@ You can now activate the environment with .. code:: bash - source .nox/dev/bin/activate + source venv/bin/activate .. tab:: Windows .. code:: bash - .nox\dev\Scripts\activate.bat + venv\Scripts\activate.bat and run the tests to check your installation. diff --git a/noxfile.py b/noxfile.py index c215c73ca5..430ad59659 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,7 @@ import nox import os import sys +from pathlib import Path # Options to modify nox behaviour @@ -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): @@ -116,18 +118,19 @@ def run_scripts(session): 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("cmake", silent=False) - if sys.platform == "linux" or sys.platform == "darwin": - session.run( - "echo", - "export", - f"LD_LIBRARY_PATH={PYBAMM_ENV['LD_LIBRARY_PATH']}", - ">>", - f"{envbindir}/activate", - external=True, # silence warning about echo being an external command + session.install("virtualenv", "cmake") + session.run("virtualenv", os.fsdecode(VENV_DIR), silent=True) + python = os.fsdecode(VENV_DIR.joinpath("bin/python")) + if sys.platform == "linux": + session.run(python, + "-m", + "pip", + "install", + ".[all,dev,jax,odes]", + external=True, ) + else: + session.run(python, "-m", "pip", "install", "-e", ".[all,dev]", external=True) @nox.session(name="tests")