Skip to content

Commit

Permalink
Revamp SUNDIALS and SuiteSparse installation script (#3719)
Browse files Browse the repository at this point in the history
Replace wget with urllib for downloading and parallelize with concurrent.futures for efficiency
  • Loading branch information
agriyakhetarpal authored Jan 16, 2024
2 parents 3e57733 + 59eb517 commit 19fc453
Show file tree
Hide file tree
Showing 3 changed files with 320 additions and 137 deletions.
37 changes: 37 additions & 0 deletions docs/source/user_guide/installation/install-from-source.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ If you are running windows, you can simply skip this section and jump to :ref:`p
This will download, compile and install the SuiteSparse and SUNDIALS libraries.
Both libraries are installed in ``~/.local``.

For users requiring more control over the installation process, the ``pybamm-requires`` session supports additional command-line arguments:

- ``--install-dir``: Specify a custom installation directory for SUNDIALS and SuiteSparse.

Example:

.. code:: bash
nox -s pybamm-requires -- --install-dir [custom_directory_path]
- ``--force``: Force the installation of SUNDIALS and SuiteSparse, even if they are already found in the specified directory.

Example:

.. code:: bash
nox -s pybamm-requires -- --force
Manual install of build time requirements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand All @@ -98,6 +116,25 @@ PyBaMM ships with a Python script that automates points 2. and 3. You can run it
python scripts/install_KLU_Sundials.py
This script supports optional arguments for custom installations:

- ``--install-dir``: Specify a custom installation directory for SUNDIALS and SuiteSparse.
By default, they are installed in ``~/.local``.

Example:

.. code:: bash
python scripts/install_KLU_Sundials.py --install-dir [custom_directory_path]
- ``--force``: Force the installation of SUNDIALS and SuiteSparse, even if they are already found in the specified directory.

Example:

.. code:: bash
python scripts/install_KLU_Sundials.py --force
.. _pybamm-install:

Installing PyBaMM
Expand Down
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def set_environment_variables(env_dict, session):

@nox.session(name="pybamm-requires")
def run_pybamm_requires(session):
"""Download, compile, and install the build-time requirements for Linux and macOS: the SuiteSparse and SUNDIALS libraries."""
"""Download, compile, and install the build-time requirements for Linux and macOS. Supports --install-dir for custom installation paths and --force to force installation."""
set_environment_variables(PYBAMM_ENV, session=session)
if sys.platform != "win32":
session.install("wget", "cmake", silent=False)
session.run("python", "scripts/install_KLU_Sundials.py")
session.install("cmake", silent=False)
session.run("python", "scripts/install_KLU_Sundials.py", *session.posargs)
if not os.path.exists("./pybind11"):
session.run(
"git",
Expand Down
Loading

0 comments on commit 19fc453

Please sign in to comment.