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

Support Python 3.12 #3531

Merged
merged 21 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
73a5132
Update python version bounds and add classifier
agriyakhetarpal Nov 16, 2023
93915b3
Update installation instructions to add 3.12
agriyakhetarpal Nov 16, 2023
92a298b
Bump RTD docs to 3.12
agriyakhetarpal Nov 16, 2023
7e451a3
Bump Python version in workflows
agriyakhetarpal Nov 16, 2023
0db07c7
Add a custom `install_PyBaMM` callable
agriyakhetarpal Nov 16, 2023
8d6a16c
Check coverage on Python 3.11 for now, run unit tests on 3.12
agriyakhetarpal Nov 16, 2023
e38e0be
Undo custom install command function
agriyakhetarpal Nov 23, 2023
a59378b
Add a `sys.version_info()` condition instead
agriyakhetarpal Nov 23, 2023
850bb05
Merge branch 'develop' into support-python-3.12
agriyakhetarpal Nov 23, 2023
84f4007
Add EOL to workflow file, fix pre-commit
agriyakhetarpal Nov 23, 2023
49622d8
Install prerequisites not present in Python 3.12
agriyakhetarpal Nov 23, 2023
1763268
Merge branch 'develop' into support-python-3.12
agriyakhetarpal Dec 8, 2023
3aa0892
Check coverage on 3.11 for now
agriyakhetarpal Dec 8, 2023
b647035
Ignore pytest cache
agriyakhetarpal Dec 8, 2023
d681070
Mention unavailability of `[odes]` on Python 3.12
agriyakhetarpal Dec 8, 2023
d4a8e9f
Add Python 3.12 support and trove classifier
agriyakhetarpal Dec 8, 2023
3bc79c7
Remove references to and imports of `distutils`
agriyakhetarpal Dec 8, 2023
168fcb0
Add checks revolving Python 3.12 and `[odes]`
agriyakhetarpal Dec 8, 2023
5753dbb
Update CHANGELOG to reflect Python 3.12 support
agriyakhetarpal Dec 8, 2023
723998d
Merge branch 'develop' into support-python-3.12
agriyakhetarpal Dec 9, 2023
61cc1c8
Fix editable installation error
agriyakhetarpal Dec 9, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12

- name: Install dependencies
run: pip install --upgrade pip setuptools wheel
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/run_periodic_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12

- name: Check style
run: |
Expand All @@ -46,7 +46,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
if: matrix.os != 'windows-latest'
run: python -m nox -s pybamm-requires

- name: Run unit tests for GNU/Linux with Python 3.8, 3.9, and 3.10, and for macOS and Windows with all Python versions
- name: Run unit tests for GNU/Linux with Python 3.8, 3.9, 3.10, and 3.12; and for macOS and Windows with all Python versions
if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11) || (matrix.os != 'ubuntu-latest')
run: python -m nox -s unit

Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand Down
46 changes: 24 additions & 22 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12

- name: Check style
run: |
Expand All @@ -38,8 +38,9 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
# We check coverage on Ubuntu with Python 3.11, so we skip unit tests for it here
# TODO: check coverage with Python 3.12 when [odes] supports it
exclude:
- os: ubuntu-latest
python-version: "3.11"
Expand Down Expand Up @@ -116,6 +117,7 @@ jobs:
run: python -m nox -s unit

# Runs only on Ubuntu with Python 3.11
# TODO: check coverage with Python 3.12 when [odes] supports it
check_coverage:
needs: style
runs-on: ubuntu-latest
Expand Down Expand Up @@ -180,7 +182,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
name: Integration tests (${{ matrix.os }} / Python ${{ matrix.python-version }})

steps:
Expand Down Expand Up @@ -253,14 +255,14 @@ jobs:
- name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }}
run: python -m nox -s integration

# Runs only on Ubuntu with Python 3.11. Skips IDAKLU module compilation
# Runs only on Ubuntu with Python 3.12. Skips IDAKLU module compilation
# for speedups, which is already tested in other jobs.
run_doctests:
needs: style
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Doctests (ubuntu-latest / Python 3.11)
name: Doctests (ubuntu-latest / Python 3.12)

steps:
- name: Check out PyBaMM repository
Expand All @@ -270,39 +272,39 @@ jobs:
- name: Install Linux system dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.3.1
with:
packages: gfortran gcc graphviz pandoc
packages: graphviz pandoc
execute_install_scripts: true

# dot -c is for registering graphviz fonts and plugins
- name: Install OpenBLAS and TeXLive for Linux
- name: Install TeXLive for Linux
run: |
sudo apt-get update
sudo dot -c
sudo apt-get install libopenblas-dev texlive-latex-extra dvipng
sudo apt-get install texlive-latex-extra dvipng

- name: Set up Python 3.11
- name: Set up Python 3.12
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12
cache: 'pip'

- name: Install nox
run: python -m pip install nox

- name: Install docs dependencies and run doctests for GNU/Linux with Python 3.11
- name: Install docs dependencies and run doctests for GNU/Linux with Python 3.12
run: python -m nox -s doctests

- name: Check if the documentation can be built for GNU/Linux with Python 3.11
- name: Check if the documentation can be built for GNU/Linux with Python 3.12
run: python -m nox -s docs

# Runs only on Ubuntu with Python 3.11
# Runs only on Ubuntu with Python 3.12
run_example_tests:
needs: style
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Example notebooks (ubuntu-latest / Python 3.11)
name: Example notebooks (ubuntu-latest / Python 3.12)

steps:
- name: Check out PyBaMM repository
Expand All @@ -322,11 +324,11 @@ jobs:
sudo dot -c
sudo apt-get install libopenblas-dev texlive-latex-extra dvipng

- name: Set up Python 3.11
- name: Set up Python 3.12
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12
cache: 'pip'

- name: Install nox
Expand All @@ -348,16 +350,16 @@ jobs:
- name: Install SuiteSparse and SUNDIALS on GNU/Linux
run: python -m nox -s pybamm-requires

- name: Run example notebooks tests for GNU/Linux with Python 3.11
- name: Run example notebooks tests for GNU/Linux with Python 3.12
run: python -m nox -s examples

# Runs only on Ubuntu with Python 3.11
# Runs only on Ubuntu with Python 3.12
run_scripts_tests:
needs: style
runs-on: ubuntu-latest
strategy:
fail-fast: false
name: Example scripts (ubuntu-latest / Python 3.11)
name: Example scripts (ubuntu-latest / Python 3.12)

steps:
- name: Check out PyBaMM repository
Expand All @@ -377,11 +379,11 @@ jobs:
sudo dot -c
sudo apt-get install libopenblas-dev texlive-latex-extra dvipng

- name: Set up Python 3.11
- name: Set up Python 3.12
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: 3.12
cache: 'pip'

- name: Install nox
Expand All @@ -403,5 +405,5 @@ jobs:
- name: Install SuiteSparse and SUNDIALS on GNU/Linux
run: python -m nox -s pybamm-requires

- name: Run example scripts tests for GNU/Linux with Python 3.11
- name: Run example scripts tests for GNU/Linux with Python 3.12
run: python -m nox -s scripts
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ setup.log
# test
test.c
test.json
.pytest_cache/

# tox
.tox/
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ build:
- "graphviz"
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- Added support for Python 3.12 ([#3531](https://github.com/pybamm-team/PyBaMM/pull/3531))
- Added method to get QuickPlot axes by variable ([#3596](https://github.com/pybamm-team/PyBaMM/pull/3596))
- Added custom experiment terminations ([#3596](https://github.com/pybamm-team/PyBaMM/pull/3596))
- Mechanical parameters are now a function of stoichiometry and temperature ([#3576](https://github.com/pybamm-team/PyBaMM/pull/3576))
Expand Down
14 changes: 11 additions & 3 deletions docs/source/user_guide/installation/GNU-linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GNU-Linux & MacOS
Prerequisites
-------------

To use PyBaMM, you must have Python 3.8, 3.9, 3.10, or 3.11 installed.
To use PyBaMM, you must have Python 3.8, 3.9, 3.10, 3.11, or 3.12 installed.

.. tab:: Debian-based distributions (Debian, Ubuntu, Linux Mint)

Expand Down Expand Up @@ -50,7 +50,7 @@ User install

We recommend to install PyBaMM within a virtual environment, in order
not to alter any distribution Python files.
First, make sure you are using Python 3.8, 3.9, 3.10, or 3.11.
First, make sure you are using Python 3.8, 3.9, 3.10, 3.11, or 3.12.
To create a virtual environment ``env`` within your current directory type:

.. code:: bash
Expand Down Expand Up @@ -105,7 +105,15 @@ Optional - scikits.odes solver
Users can install `scikits.odes <https://github.com/bmcage/odes>`__ in
order to use the wrapped SUNDIALS ODE and DAE
`solvers <https://docs.pybamm.org/en/latest/source/api/solvers/scikits_solvers.html>`__.
Currently, only GNU/Linux and macOS are supported.

.. note::

Currently, only GNU/Linux and macOS are supported.

.. note::

The ``scikits.odes`` solver is not supported on Python 3.12 yet, please refer to https://github.com/bmcage/odes/issues/162.
There is support for Python 3.8, 3.9, 3.10, and 3.11.

.. tab:: GNU/Linux

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ or download the source archive on the repository's homepage.

To install PyBaMM, you will need:

- Python 3 (PyBaMM supports versions 3.8, 3.9, 3.10, and 3.11)
- Python 3 (PyBaMM supports versions 3.8, 3.9, 3.10, 3.11, and 3.12)
- The Python headers file for your current Python version.
- A BLAS library (for instance `openblas <https://www.openblas.net/>`_).
- A C compiler (ex: ``gcc``).
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/installation/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Windows
Prerequisites
-------------

To use PyBaMM, you must have Python 3.8, 3.9, 3.10, or 3.11 installed.
To use PyBaMM, you must have Python 3.8, 3.9, 3.10, 3.11, or 3.12 installed.

To install Python 3 download the installation files from `Python’s
website <https://www.python.org/downloads/windows/>`__. Make sure to
Expand Down
62 changes: 38 additions & 24 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

def set_environment_variables(env_dict, session):
"""
Sets environment variables for a nox session object.
Sets environment variables for a nox Session object.

Parameters
-----------
Expand Down Expand Up @@ -61,7 +61,10 @@ def run_coverage(session):
set_environment_variables(PYBAMM_ENV, session=session)
session.install("coverage", silent=False)
if sys.platform != "win32":
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
session.install("-e", ".[all,jax,odes]", silent=False)
if sys.version_info > (3, 12):
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
session.install("-e", ".[all,jax]", silent=False)
else:
session.install("-e", ".[all,jax,odes]", silent=False)
else:
if sys.version_info < (3, 9):
session.install("-e", ".[all]", silent=False)
Expand All @@ -77,7 +80,10 @@ def run_integration(session):
"""Run the integration tests."""
set_environment_variables(PYBAMM_ENV, session=session)
if sys.platform != "win32":
session.install("-e", ".[all,jax,odes]", silent=False)
if sys.version_info > (3, 12):
session.install("-e", ".[all,jax]", silent=False)
else:
session.install("-e", ".[all,jax,odes]", silent=False)
else:
if sys.version_info < (3, 9):
session.install("-e", ".[all]", silent=False)
Expand All @@ -98,7 +104,10 @@ def run_unit(session):
"""Run the unit tests."""
set_environment_variables(PYBAMM_ENV, session=session)
if sys.platform != "win32":
session.install("-e", ".[all,jax,odes]", silent=False)
if sys.version_info > (3, 12):
session.install("-e", ".[all,jax]", silent=False)
else:
session.install("-e", ".[all,jax,odes]", silent=False)
else:
if sys.version_info < (3, 9):
session.install("-e", ".[all]", silent=False)
Expand Down Expand Up @@ -131,34 +140,35 @@ def set_dev(session):
session.install("virtualenv", "cmake")
session.run("virtualenv", os.fsdecode(VENV_DIR), silent=True)
python = os.fsdecode(VENV_DIR.joinpath("bin/python"))
session.run(
python,
"-m",
"pip",
"install",
"--upgrade",
"pip",
"setuptools",
"wheel",
external=True,
)
if sys.platform == "linux":
session.run(
python,
"-m",
"pip",
"install",
"-e",
".[all,dev,jax,odes]",
external=True,
)
if sys.version_info > (3, 12):
session.run(
python,
"-m",
"pip",
"install",
"-e",
".[all,dev,jax]",
external=True,
)
else:
session.run(
python,
"-m",
"pip",
"install",
"-e",
".[all,dev,jax,odes]",
external=True,
)
else:
if sys.version_info < (3, 9):
session.run(
python,
"-m",
"pip",
"install",
"-e",
".[all,dev]",
external=True,
)
Expand All @@ -168,6 +178,7 @@ def set_dev(session):
"-m",
"pip",
"install",
"-e",
".[all,dev,jax]",
external=True,
)
Expand All @@ -178,6 +189,9 @@ def run_tests(session):
"""Run the unit tests and integration tests sequentially."""
set_environment_variables(PYBAMM_ENV, session=session)
if sys.platform != "win32":
if sys.version_info > (3, 12):
session.install("-e", ".[all,jax]", silent=False)
else:
session.install("-e", ".[all,jax,odes]", silent=False)
else:
if sys.version_info < (3, 9):
Expand Down
Loading
Loading