diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 3073c95f09..5b8c18c399 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -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 diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index 020ac37f86..b01e9a39e8 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -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: | @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 10fc5f53a8..8d6f5a16e5 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -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: | @@ -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" @@ -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 @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index 612dc777b1..7e28f2da7d 100644 --- a/.gitignore +++ b/.gitignore @@ -110,6 +110,7 @@ setup.log # test test.c test.json +.pytest_cache/ # tox .tox/ diff --git a/.readthedocs.yaml b/.readthedocs.yaml index f907ac23d5..fb84bce9cb 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -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" diff --git a/CHANGELOG.md b/CHANGELOG.md index 82f07dea29..092cb92b46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/docs/source/user_guide/installation/GNU-linux.rst b/docs/source/user_guide/installation/GNU-linux.rst index cf027db587..8c3c00f133 100644 --- a/docs/source/user_guide/installation/GNU-linux.rst +++ b/docs/source/user_guide/installation/GNU-linux.rst @@ -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) @@ -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 @@ -105,7 +105,15 @@ Optional - scikits.odes solver Users can install `scikits.odes `__ in order to use the wrapped SUNDIALS ODE and DAE `solvers `__. -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 diff --git a/docs/source/user_guide/installation/install-from-source.rst b/docs/source/user_guide/installation/install-from-source.rst index 003c7f143a..26b6b5cf20 100644 --- a/docs/source/user_guide/installation/install-from-source.rst +++ b/docs/source/user_guide/installation/install-from-source.rst @@ -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 `_). - A C compiler (ex: ``gcc``). diff --git a/docs/source/user_guide/installation/windows.rst b/docs/source/user_guide/installation/windows.rst index 5ad77b6f7f..6e815b33c8 100644 --- a/docs/source/user_guide/installation/windows.rst +++ b/docs/source/user_guide/installation/windows.rst @@ -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 `__. Make sure to diff --git a/noxfile.py b/noxfile.py index 297fc5b3d7..4805bff83c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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 ----------- @@ -61,7 +61,10 @@ def run_coverage(session): set_environment_variables(PYBAMM_ENV, session=session) session.install("coverage", silent=False) 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) @@ -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) @@ -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) @@ -131,27 +140,27 @@ 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( @@ -159,6 +168,7 @@ def set_dev(session): "-m", "pip", "install", + "-e", ".[all,dev]", external=True, ) @@ -168,6 +178,7 @@ def set_dev(session): "-m", "pip", "install", + "-e", ".[all,dev,jax]", external=True, ) @@ -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): diff --git a/pyproject.toml b/pyproject.toml index 7d25c8e140..bc8fe267e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ license = { file = "LICENSE.txt" } description = "Python Battery Mathematical Modelling" authors = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] maintainers = [{name = "The PyBaMM Team", email = "pybamm@pybamm.org"}] -requires-python = ">=3.8, <3.12" +requires-python = ">=3.8, <3.13" readme = {file = "README.md", content-type = "text/markdown"} classifiers = [ "Development Status :: 5 - Production/Stable", @@ -29,6 +29,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering", ] dependencies = [ diff --git a/setup.py b/setup.py index ef82e65e70..db5be76181 100644 --- a/setup.py +++ b/setup.py @@ -6,14 +6,9 @@ from platform import system import wheel.bdist_wheel as orig -try: - from setuptools import setup, Extension - from setuptools.command.install import install - from setuptools.command.build_ext import build_ext -except ImportError: - from distutils.core import setup - from distutils.command.install import install - from distutils.command.build_ext import build_ext +from setuptools import setup, Extension +from setuptools.command.install import install +from setuptools.command.build_ext import build_ext default_lib_dir = ( @@ -71,9 +66,9 @@ def finalize_options(self): self.sundials_root = os.path.join(default_lib_dir) def get_build_directory(self): - # distutils outputs object files in directory self.build_temp + # setuptools outputs object files in directory self.build_temp # (typically build/temp.*). This is our CMake build directory. - # On Windows, distutils is too smart and appends "Release" or + # On Windows, setuptools is too smart and appends "Release" or # "Debug" to self.build_temp. So in this case we want the # build directory to be the parent directory. if system() == "Windows":