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 minor bugs in install_odes.py #1916

Merged
merged 6 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

- The `domain` setter and `auxiliary_domains` getter have been deprecated, `domains` setter/getter should be used instead. The `domain` getter is still active. We now recommend creating symbols with `domains={...}` instead of `domain=..., auxiliary_domains={...}`, but the latter is not yet deprecated ([#1866](https://github.com/pybamm-team/PyBaMM/pull/1866))

## Bug fixes

- `scikit.odes` and `SUNDIALS` can now be installed using `pybamm_install_odes` ([#1916](https://github.com/pybamm-team/PyBaMM/pull/1916))

# [v22.1](https://github.com/pybamm-team/PyBaMM/tree/v22.1) - 2022-01-31

## Features
Expand Down
4 changes: 2 additions & 2 deletions docs/install/GNU-linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ On Fedora or CentOS, you can use DNF or Yum. For example
sudo dnf install python3

On Mac OS distributions, you can use ``homebrew``. First `install
``brew`` <https://docs.python-guide.org/starting/install3/osx/>`__:
brew <https://docs.python-guide.org/starting/install3/osx/>`__:

.. code:: bash

Expand Down Expand Up @@ -105,7 +105,7 @@ GNU/Linux
.. code:: bash

apt install libopenblas-dev
pybamm_install_odes --install-sundials
pybamm_install_odes

The ``pybamm_install_odes`` command is installed with PyBaMM. It automatically downloads and installs the SUNDIALS library on your
system (under ``~/.local``), before installing ``sckits.odes`` (by running ``pip install scikits.odes``).
Expand Down
15 changes: 10 additions & 5 deletions pybamm/install_odes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
import subprocess

from pybamm.util import root_dir as pybamm_dir
from pybamm.util import root_dir

try:
# wget module is required to download SUNDIALS or SuiteSparse.
Expand Down Expand Up @@ -41,8 +41,10 @@ def install_sundials(download_dir, install_dir):
raise RuntimeError("CMake must be installed to build SUNDIALS.")

url = (
"https://computing.llnl.gov/"
+ "projects/sundials/download/sundials-{}.tar.gz".format(sundials_version)
"https://github.com/LLNL/"
+ "sundials/releases/download/v{}/sundials-{}.tar.gz".format(
sundials_version, sundials_version
)
)
logger.info("Downloading sundials")
download_extract_library(url, download_dir)
Expand Down Expand Up @@ -128,6 +130,8 @@ def main(arguments=None):
default_install_dir = os.path.join(os.getenv("HOME"), ".local")
parser.add_argument("--install-dir", type=str, default=default_install_dir)
args = parser.parse_args(arguments)

pybamm_dir = root_dir()
install_dir = (
args.install_dir
if os.path.isabs(args.install_dir)
Expand All @@ -144,18 +148,19 @@ def main(arguments=None):
SUNDIALS_FOUND = isfile(join(DIR, "lib", "libsundials_ida.so")) or isfile(
join(DIR, "lib", "libsundials_ida.dylib")
)
SUNDIALS_LIB_DIR = DIR if SUNDIALS_FOUND else ""
if SUNDIALS_FOUND:
SUNDIALS_LIB_DIR = DIR
logger.info("Found sundials at {}".format(SUNDIALS_LIB_DIR))
break

if not SUNDIALS_FOUND:
logger.info("Could not find sundials libraries.")
logger.info("Installing sundials in {}".install_dir)
logger.info("Installing sundials in {}".format(install_dir))
download_dir = os.path.join(pybamm_dir, "sundials")
if not os.path.exists(download_dir):
os.makedirs(download_dir)
install_sundials(download_dir, install_dir)
SUNDIALS_LIB_DIR = install_dir

update_LD_LIBRARY_PATH(SUNDIALS_LIB_DIR)

Expand Down