From 73a5132e80ffcdd992dceda355bb96212d3d12c8 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 17 Nov 2023 03:12:29 +0530 Subject: [PATCH 01/18] Update python version bounds and add classifier --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fca5b83de8..c5dad3fae1 100644 --- a/setup.py +++ b/setup.py @@ -186,7 +186,7 @@ def compile_KLU(): }, package_data={"pybamm": pybamm_data}, # Python version - python_requires=">=3.8,<3.12", + python_requires=">=3.8,<3.13", classifiers=[ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -199,6 +199,7 @@ def compile_KLU(): "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering", ], # List of dependencies From 93915b3df43a9c9170798946470f9f1d8cd1d74f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 17 Nov 2023 03:12:58 +0530 Subject: [PATCH 02/18] Update installation instructions to add 3.12 --- docs/source/user_guide/installation/GNU-linux.rst | 4 ++-- docs/source/user_guide/installation/install-from-source.rst | 2 +- docs/source/user_guide/installation/windows.rst | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/user_guide/installation/GNU-linux.rst b/docs/source/user_guide/installation/GNU-linux.rst index e66c3c2291..66df93d939 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 and/or contribute to PyBaMM, you must have Python 3.8, 3.9, 3.10, or 3.11 installed. +To use and/or contribute to 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 diff --git a/docs/source/user_guide/installation/install-from-source.rst b/docs/source/user_guide/installation/install-from-source.rst index fb448950bf..41e89a959b 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 6ff48293bd..08f261f72f 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 and/or contribute to PyBaMM, you must have Python 3.8, 3.9, 3.10, or 3.11 installed. +To use and/or contribute to 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 From 92a298be0b91ae20d7615fe4d4f7712792ba5e26 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 17 Nov 2023 03:13:07 +0530 Subject: [PATCH 03/18] Bump RTD docs to 3.12 --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 7e451a36a9bda2becfc926346c7cdfb7c3ae2acd Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 17 Nov 2023 03:14:28 +0530 Subject: [PATCH 04/18] Bump Python version in workflows for PyPI pushes, scheduled tests, and tests on PRs --- .github/workflows/publish_pypi.yml | 2 +- .github/workflows/run_periodic_tests.yml | 16 ++++---- .github/workflows/test_on_push.yml | 52 ++++++++++++------------ 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 7d01fe0bee..be80007c67 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -138,7 +138,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 build diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index f6e51bc11b..b3c265c829 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -36,7 +36,7 @@ jobs: - name: Setup python uses: actions/setup-python@v4 with: - python-version: 3.11 + python-version: 3.12 - name: Check style run: | @@ -50,7 +50,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 @@ -92,16 +92,16 @@ jobs: if: matrix.os == 'ubuntu-latest' run: pipx run 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 - if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.11) || (matrix.os != 'ubuntu-latest') + - name: Run unit tests for GNU/Linux with Python 3.8, 3.9, 3.10, and 3.11 and for macOS and Windows with all Python versions + if: (matrix.os == 'ubuntu-latest' && matrix.python-version != 3.12) || (matrix.os != 'ubuntu-latest') run: pipx run nox -s unit - - name: Run unit tests for GNU/Linux with Python 3.11 and generate coverage report - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 + - name: Run unit tests for GNU/Linux with Python 3.12 and generate coverage report + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.12 run: pipx run nox -s coverage - name: Upload coverage report - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.12 uses: codecov/codecov-action@v3.1.4 - name: Run integration tests @@ -132,7 +132,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 db71c32586..89f44ef3a4 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: | @@ -37,11 +37,11 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] - # We check coverage on Ubuntu with Python 3.11, so we skip unit tests for it here + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + # We check coverage on Ubuntu with Python 3.12, so we skip unit tests for it here exclude: - os: ubuntu-latest - python-version: "3.11" + python-version: "3.12" name: Unit tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: @@ -116,13 +116,13 @@ jobs: - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: pipx run nox -s unit - # Runs only on Ubuntu with Python 3.11 + # Runs only on Ubuntu with Python 3.12 check_coverage: needs: style runs-on: ubuntu-latest strategy: fail-fast: false - name: Coverage tests (ubuntu-latest / Python 3.11) + name: Coverage tests (ubuntu-latest / Python 3.12) steps: - name: Check out PyBaMM repository @@ -142,11 +142,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' cache-dependency-path: setup.py @@ -171,7 +171,7 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: pipx run nox -s pybamm-requires - - name: Run unit tests for Ubuntu with Python 3.11 and generate coverage report + - name: Run unit tests for Ubuntu with Python 3.12 and generate coverage report run: pipx run nox -s coverage - name: Upload coverage report @@ -184,7 +184,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: @@ -259,14 +259,14 @@ jobs: - name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: pipx run 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 @@ -286,11 +286,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' cache-dependency-path: setup.py @@ -299,19 +299,19 @@ jobs: pip install --upgrade pip wheel setuptools pip install -e .[all,docs] - - 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: pipx run 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: pipx run 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 @@ -331,11 +331,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' cache-dependency-path: setup.py @@ -360,16 +360,16 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: pipx run nox -s pybamm-requires - - name: Install dev dependencies and run example tests for GNU/Linux with Python 3.11 + - name: Install dev dependencies and run example tests for GNU/Linux with Python 3.12 run: pipx run 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 @@ -389,11 +389,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' cache-dependency-path: setup.py @@ -418,5 +418,5 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: pipx run nox -s pybamm-requires - - name: Install dev dependencies and run example scripts tests for GNU/Linux with Python 3.11 + - name: Install dev dependencies and run example scripts tests for GNU/Linux with Python 3.12 run: pipx run nox -s scripts From 0db07c70f0347f452fd6faef2e9bf8f61357d30d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 17 Nov 2023 03:15:05 +0530 Subject: [PATCH 05/18] Add a custom `install_PyBaMM` callable --- noxfile.py | 65 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/noxfile.py b/noxfile.py index 430ad59659..7c77680800 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 ----------- @@ -36,6 +36,38 @@ def set_environment_variables(env_dict, session): session.env[key] = value +def install_PyBaMM(session, extras): + """ + Installs PyBaMM in editable mode along with its dependencies for + a nox Session object. + + Parameters + ----------- + session : nox.Session + The session to install dependencies for. + extras : list[str] + A list of dependencies to install. The current + options are: + [all,dev,jax,odes,docs] + + """ + # TODO: Remove this mess once [odes] brings support for Python 3.12 + # See https://github.com/bmcage/odes/issues/162 for details. + + # FIXME: Bump [jax] to get compatibility with Python 3.12 and Windows in this PR + + # For now: silently remove [odes] and [jax] if specified, when running on + # 1. Linux and macOS on Python 3.12 + # 2. Windows on any Python version + + if sys.platform == "win32" or sys.version_info >= (3, 12): + if "odes" in extras or "jax" in extras: + extras.remove("odes") + extras.remove("jax") + + session.install("-e", f".[{','.join(extras)}]", silent=False) + + @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.""" # noqa: E501 @@ -60,10 +92,10 @@ def run_coverage(session): """Run the coverage tests and generate an XML report.""" set_environment_variables(PYBAMM_ENV, session=session) session.install("coverage", silent=False) - session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - session.install("-e", ".[odes]", silent=False) - session.install("-e", ".[jax]", silent=False) + install_PyBaMM(session=session, extras=["all","odes","jax"]) + else: + install_PyBaMM(session=session, extras=["all"]) session.run("coverage", "run", "--rcfile=.coveragerc", "run-tests.py", "--nosub") session.run("coverage", "combine") session.run("coverage", "xml") @@ -73,16 +105,17 @@ def run_coverage(session): def run_integration(session): """Run the integration tests.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("-e", ".[all]", silent=False) if sys.platform == "linux": - session.install("-e", ".[odes]", silent=False) + install_PyBaMM(session=session, extras=["all","odes","jax"]) + else: + install_PyBaMM(session=session, extras=["all"]) session.run("python", "run-tests.py", "--integration") @nox.session(name="doctests") def run_doctests(session): """Run the doctests and generate the output(s) in the docs/build/ directory.""" - session.install("-e", ".[all,docs]", silent=False) + install_PyBaMM(session=session, extras=["all","docs"]) session.run("python", "run-tests.py", "--doctest") @@ -90,10 +123,10 @@ def run_doctests(session): def run_unit(session): """Run the unit tests.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("-e", ".[all]", silent=False) if sys.platform == "linux": - session.install("-e", ".[odes]", silent=False) - session.install("-e", ".[jax]", silent=False) + install_PyBaMM(session=session, extras=["all","odes","jax"]) + else: + install_PyBaMM(session=session, extras=["all"]) session.run("python", "run-tests.py", "--unit") @@ -101,7 +134,7 @@ def run_unit(session): def run_examples(session): """Run the examples tests for Jupyter notebooks.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("-e", ".[all,dev]", silent=False) + install_PyBaMM(session=session, extras=["all","dev"]) notebooks_to_test = session.posargs if session.posargs else [] session.run("pytest", "--nbmake", *notebooks_to_test, external=True) @@ -110,7 +143,7 @@ def run_examples(session): def run_scripts(session): """Run the scripts tests for Python scripts.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("-e", ".[all]", silent=False) + install_PyBaMM(session=session, extras=["all"]) session.run("python", "run-tests.py", "--scripts") @@ -137,10 +170,10 @@ def set_dev(session): def run_tests(session): """Run the unit tests and integration tests sequentially.""" set_environment_variables(PYBAMM_ENV, session=session) - session.install("-e", ".[all]", silent=False) if sys.platform == "linux" or sys.platform == "darwin": - session.install("-e", ".[odes]", silent=False) - session.install("-e", ".[jax]", silent=False) + install_PyBaMM(session=session, extras=["all","odes","jax"]) + else: + install_PyBaMM(session=session, extras=["all"]) session.run("python", "run-tests.py", "--all") @@ -148,7 +181,7 @@ def run_tests(session): def build_docs(session): """Build the documentation and load it in a browser tab, rebuilding on changes.""" envbindir = session.bin - session.install("-e", ".[all,docs]", silent=False) + install_PyBaMM(session=session, extras=["all","docs"]) session.chdir("docs") # Local development if session.interactive: From 8d6a16c21cc6d412e0cb05c936b4396bd1838394 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 17 Nov 2023 03:17:34 +0530 Subject: [PATCH 06/18] Check coverage on Python 3.11 for now, run unit tests on 3.12 --- .github/workflows/test_on_push.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 89f44ef3a4..59d1805cdc 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -38,10 +38,11 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - # We check coverage on Ubuntu with Python 3.12, so we skip unit tests for it here + # 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] and [jax] support it exclude: - os: ubuntu-latest - python-version: "3.12" + python-version: "3.11" name: Unit tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: @@ -116,13 +117,14 @@ jobs: - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} run: pipx run nox -s unit - # Runs only on Ubuntu with Python 3.12 + # Runs only on Ubuntu with Python 3.11 + # TODO: check coverage with Python 3.12 when [odes] and [jax] support it check_coverage: needs: style runs-on: ubuntu-latest strategy: fail-fast: false - name: Coverage tests (ubuntu-latest / Python 3.12) + name: Coverage tests (ubuntu-latest / Python 3.11) steps: - name: Check out PyBaMM repository @@ -142,11 +144,11 @@ jobs: sudo dot -c sudo apt-get install libopenblas-dev texlive-latex-extra dvipng - - name: Set up Python 3.12 + - name: Set up Python 3.11 id: setup-python uses: actions/setup-python@v4 with: - python-version: 3.12 + python-version: 3.11 cache: 'pip' cache-dependency-path: setup.py @@ -171,7 +173,7 @@ jobs: - name: Install SuiteSparse and SUNDIALS on GNU/Linux run: pipx run nox -s pybamm-requires - - name: Run unit tests for Ubuntu with Python 3.12 and generate coverage report + - name: Run unit tests for Ubuntu with Python 3.11 and generate coverage report run: pipx run nox -s coverage - name: Upload coverage report From e38e0be445ab0dc9f8775e4e4cfcd9ad4fd6a397 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 23 Nov 2023 15:39:16 +0530 Subject: [PATCH 07/18] Undo custom install command function This reverts commit 0db07c70f0347f452fd6faef2e9bf8f61357d30d. --- noxfile.py | 63 +++++++++++++----------------------------------------- 1 file changed, 15 insertions(+), 48 deletions(-) diff --git a/noxfile.py b/noxfile.py index 7c77680800..d485d4c3a1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -36,38 +36,6 @@ def set_environment_variables(env_dict, session): session.env[key] = value -def install_PyBaMM(session, extras): - """ - Installs PyBaMM in editable mode along with its dependencies for - a nox Session object. - - Parameters - ----------- - session : nox.Session - The session to install dependencies for. - extras : list[str] - A list of dependencies to install. The current - options are: - [all,dev,jax,odes,docs] - - """ - # TODO: Remove this mess once [odes] brings support for Python 3.12 - # See https://github.com/bmcage/odes/issues/162 for details. - - # FIXME: Bump [jax] to get compatibility with Python 3.12 and Windows in this PR - - # For now: silently remove [odes] and [jax] if specified, when running on - # 1. Linux and macOS on Python 3.12 - # 2. Windows on any Python version - - if sys.platform == "win32" or sys.version_info >= (3, 12): - if "odes" in extras or "jax" in extras: - extras.remove("odes") - extras.remove("jax") - - session.install("-e", f".[{','.join(extras)}]", silent=False) - - @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.""" # noqa: E501 @@ -92,10 +60,10 @@ def run_coverage(session): """Run the coverage tests and generate an XML report.""" set_environment_variables(PYBAMM_ENV, session=session) session.install("coverage", silent=False) + session.install("-e", ".[all]", silent=False) if sys.platform != "win32": - install_PyBaMM(session=session, extras=["all","odes","jax"]) - else: - install_PyBaMM(session=session, extras=["all"]) + session.install("-e", ".[odes]", silent=False) + session.install("-e", ".[jax]", silent=False) session.run("coverage", "run", "--rcfile=.coveragerc", "run-tests.py", "--nosub") session.run("coverage", "combine") session.run("coverage", "xml") @@ -105,17 +73,16 @@ def run_coverage(session): def run_integration(session): """Run the integration tests.""" set_environment_variables(PYBAMM_ENV, session=session) + session.install("-e", ".[all]", silent=False) if sys.platform == "linux": - install_PyBaMM(session=session, extras=["all","odes","jax"]) - else: - install_PyBaMM(session=session, extras=["all"]) + session.install("-e", ".[odes]", silent=False) session.run("python", "run-tests.py", "--integration") @nox.session(name="doctests") def run_doctests(session): """Run the doctests and generate the output(s) in the docs/build/ directory.""" - install_PyBaMM(session=session, extras=["all","docs"]) + session.install("-e", ".[all,docs]", silent=False) session.run("python", "run-tests.py", "--doctest") @@ -123,10 +90,10 @@ def run_doctests(session): def run_unit(session): """Run the unit tests.""" set_environment_variables(PYBAMM_ENV, session=session) + session.install("-e", ".[all]", silent=False) if sys.platform == "linux": - install_PyBaMM(session=session, extras=["all","odes","jax"]) - else: - install_PyBaMM(session=session, extras=["all"]) + session.install("-e", ".[odes]", silent=False) + session.install("-e", ".[jax]", silent=False) session.run("python", "run-tests.py", "--unit") @@ -134,7 +101,7 @@ def run_unit(session): def run_examples(session): """Run the examples tests for Jupyter notebooks.""" set_environment_variables(PYBAMM_ENV, session=session) - install_PyBaMM(session=session, extras=["all","dev"]) + session.install("-e", ".[all,dev]", silent=False) notebooks_to_test = session.posargs if session.posargs else [] session.run("pytest", "--nbmake", *notebooks_to_test, external=True) @@ -143,7 +110,7 @@ def run_examples(session): def run_scripts(session): """Run the scripts tests for Python scripts.""" set_environment_variables(PYBAMM_ENV, session=session) - install_PyBaMM(session=session, extras=["all"]) + session.install("-e", ".[all]", silent=False) session.run("python", "run-tests.py", "--scripts") @@ -170,10 +137,10 @@ def set_dev(session): def run_tests(session): """Run the unit tests and integration tests sequentially.""" set_environment_variables(PYBAMM_ENV, session=session) + session.install("-e", ".[all]", silent=False) if sys.platform == "linux" or sys.platform == "darwin": - install_PyBaMM(session=session, extras=["all","odes","jax"]) - else: - install_PyBaMM(session=session, extras=["all"]) + session.install("-e", ".[odes]", silent=False) + session.install("-e", ".[jax]", silent=False) session.run("python", "run-tests.py", "--all") @@ -181,7 +148,7 @@ def run_tests(session): def build_docs(session): """Build the documentation and load it in a browser tab, rebuilding on changes.""" envbindir = session.bin - install_PyBaMM(session=session, extras=["all","docs"]) + session.install("-e", ".[all,docs]", silent=False) session.chdir("docs") # Local development if session.interactive: From a59378bd9cbcf9a489e159d3d064ea73af747967 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:07:47 +0530 Subject: [PATCH 08/18] Add a `sys.version_info()` condition instead --- noxfile.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/noxfile.py b/noxfile.py index d485d4c3a1..75756017e4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -61,9 +61,9 @@ def run_coverage(session): set_environment_variables(PYBAMM_ENV, session=session) session.install("coverage", silent=False) session.install("-e", ".[all]", silent=False) - if sys.platform != "win32": - session.install("-e", ".[odes]", silent=False) - session.install("-e", ".[jax]", silent=False) + if sys.platform != "win32" and sys.version_info < (3, 12): + # TODO: update this when JAX is bumped to support Python 3.12 and Windows + session.install("-e", ".[odes,jax]", silent=False) session.run("coverage", "run", "--rcfile=.coveragerc", "run-tests.py", "--nosub") session.run("coverage", "combine") session.run("coverage", "xml") @@ -74,7 +74,7 @@ def run_integration(session): """Run the integration tests.""" set_environment_variables(PYBAMM_ENV, session=session) session.install("-e", ".[all]", silent=False) - if sys.platform == "linux": + if sys.platform == "linux" and sys.version_info < (3, 12): session.install("-e", ".[odes]", silent=False) session.run("python", "run-tests.py", "--integration") @@ -91,9 +91,9 @@ def run_unit(session): """Run the unit tests.""" set_environment_variables(PYBAMM_ENV, session=session) session.install("-e", ".[all]", silent=False) - if sys.platform == "linux": - session.install("-e", ".[odes]", silent=False) - session.install("-e", ".[jax]", silent=False) + if sys.platform == "linux" and sys.version_info < (3, 12): + # TODO: update this when JAX is bumped to support Python 3.12 and Windows + session.install("-e", ".[odes,jax]", silent=False) session.run("python", "run-tests.py", "--unit") @@ -121,7 +121,8 @@ 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")) - if sys.platform == "linux": + if sys.platform == "linux" and sys.version_info < (3, 12): + # TODO: update this when JAX is bumped to support Python 3.12 and Windows session.run(python, "-m", "pip", @@ -138,9 +139,9 @@ def run_tests(session): """Run the unit tests and integration tests sequentially.""" set_environment_variables(PYBAMM_ENV, session=session) session.install("-e", ".[all]", silent=False) - if sys.platform == "linux" or sys.platform == "darwin": - session.install("-e", ".[odes]", silent=False) - session.install("-e", ".[jax]", silent=False) + if (sys.platform == "linux" or sys.platform == "darwin") and sys.version_info < (3, 12): + # TODO: update this when JAX is bumped to support Python 3.12 and Windows + session.install("-e", ".[odes,jax]", silent=False) session.run("python", "run-tests.py", "--all") From 84f4007db2dc74f9099f3aed70157fe02286791b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:13:33 +0530 Subject: [PATCH 09/18] Add EOL to workflow file, fix pre-commit --- .github/workflows/test_on_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index bfc2652368..0d3154fef4 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -413,4 +413,4 @@ jobs: run: python -m nox -s pybamm-requires - name: Install dev dependencies and run example scripts tests for GNU/Linux with Python 3.11 - run: python -m nox -s scripts \ No newline at end of file + run: python -m nox -s scripts From 49622d8fe1b1e739fb5f0df4459e79c3d4f2addd Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 23 Nov 2023 16:25:43 +0530 Subject: [PATCH 10/18] Install prerequisites not present in Python 3.12 --- noxfile.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/noxfile.py b/noxfile.py index 75756017e4..f18ce6dce0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -60,6 +60,8 @@ def run_coverage(session): """Run the coverage tests and generate an XML report.""" set_environment_variables(PYBAMM_ENV, session=session) session.install("coverage", silent=False) + # TODO: remove this when PyBaMM moves to pyproject.toml + session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("-e", ".[all]", silent=False) if sys.platform != "win32" and sys.version_info < (3, 12): # TODO: update this when JAX is bumped to support Python 3.12 and Windows @@ -73,6 +75,8 @@ def run_coverage(session): def run_integration(session): """Run the integration tests.""" set_environment_variables(PYBAMM_ENV, session=session) + # TODO: remove this when PyBaMM moves to pyproject.toml + session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("-e", ".[all]", silent=False) if sys.platform == "linux" and sys.version_info < (3, 12): session.install("-e", ".[odes]", silent=False) @@ -90,6 +94,8 @@ def run_doctests(session): def run_unit(session): """Run the unit tests.""" set_environment_variables(PYBAMM_ENV, session=session) + # TODO: remove this when PyBaMM moves to pyproject.toml + session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("-e", ".[all]", silent=False) if sys.platform == "linux" and sys.version_info < (3, 12): # TODO: update this when JAX is bumped to support Python 3.12 and Windows @@ -101,6 +107,8 @@ def run_unit(session): def run_examples(session): """Run the examples tests for Jupyter notebooks.""" set_environment_variables(PYBAMM_ENV, session=session) + # TODO: remove this when PyBaMM moves to pyproject.toml + session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("-e", ".[all,dev]", silent=False) notebooks_to_test = session.posargs if session.posargs else [] session.run("pytest", "--nbmake", *notebooks_to_test, external=True) @@ -109,6 +117,8 @@ def run_examples(session): @nox.session(name="scripts") def run_scripts(session): """Run the scripts tests for Python scripts.""" + # TODO: remove this when PyBaMM moves to pyproject.toml + session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) set_environment_variables(PYBAMM_ENV, session=session) session.install("-e", ".[all]", silent=False) session.run("python", "run-tests.py", "--scripts") @@ -118,6 +128,8 @@ def run_scripts(session): def set_dev(session): """Install PyBaMM in editable mode.""" set_environment_variables(PYBAMM_ENV, session=session) + # TODO: remove this when PyBaMM moves to pyproject.toml + session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("virtualenv", "cmake") session.run("virtualenv", os.fsdecode(VENV_DIR), silent=True) python = os.fsdecode(VENV_DIR.joinpath("bin/python")) @@ -138,6 +150,8 @@ def set_dev(session): def run_tests(session): """Run the unit tests and integration tests sequentially.""" set_environment_variables(PYBAMM_ENV, session=session) + # TODO: remove this when PyBaMM moves to pyproject.toml + session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("-e", ".[all]", silent=False) if (sys.platform == "linux" or sys.platform == "darwin") and sys.version_info < (3, 12): # TODO: update this when JAX is bumped to support Python 3.12 and Windows @@ -149,6 +163,8 @@ def run_tests(session): def build_docs(session): """Build the documentation and load it in a browser tab, rebuilding on changes.""" envbindir = session.bin + # TODO: remove this when PyBaMM moves to pyproject.toml + session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("-e", ".[all,docs]", silent=False) session.chdir("docs") # Local development From 3aa0892fb3820f80a4b1783ac48e5733e8da0d77 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:24:43 +0530 Subject: [PATCH 11/18] Check coverage on 3.11 for now --- .github/workflows/run_periodic_tests.yml | 4 ++-- .github/workflows/test_on_push.yml | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index b3a0a762fd..b01e9a39e8 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -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 @@ -89,7 +89,7 @@ jobs: run: python -m nox -s coverage - name: Upload coverage report - if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.12 + if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.11 uses: codecov/codecov-action@v3.1.4 - name: Run integration tests diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index b3a22a17a8..8d6f5a16e5 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -40,7 +40,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] 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] and [jax] support it + # TODO: check coverage with Python 3.12 when [odes] supports it exclude: - os: ubuntu-latest python-version: "3.11" @@ -117,7 +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] and [jax] support it + # TODO: check coverage with Python 3.12 when [odes] supports it check_coverage: needs: style runs-on: ubuntu-latest @@ -272,15 +272,15 @@ 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.12 id: setup-python @@ -292,10 +292,10 @@ jobs: - 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.12 @@ -350,7 +350,7 @@ 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.12 @@ -405,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 From b647035a591681a6ac37c2309f34f339705b081a Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:25:01 +0530 Subject: [PATCH 12/18] Ignore pytest cache --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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/ From d681070f5a1537e0776a3c019a6329d9d0dafeb7 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:25:37 +0530 Subject: [PATCH 13/18] Mention unavailability of `[odes]` on Python 3.12 --- docs/source/user_guide/installation/GNU-linux.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/source/user_guide/installation/GNU-linux.rst b/docs/source/user_guide/installation/GNU-linux.rst index cf9afcac1c..8c3c00f133 100644 --- a/docs/source/user_guide/installation/GNU-linux.rst +++ b/docs/source/user_guide/installation/GNU-linux.rst @@ -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 From d4a8e9f9c68048af03c36a0fcd8ae10fb2b7c933 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:25:57 +0530 Subject: [PATCH 14/18] Add Python 3.12 support and trove classifier --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 = [ From 3bc79c737a960545c66ee51d7b291cea9ca7209c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:27:14 +0530 Subject: [PATCH 15/18] Remove references to and imports of `distutils` --- setup.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) 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": From 168fcb08a3af80f42efeaea1cfd3025bb0416b28 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:47:27 +0530 Subject: [PATCH 16/18] Add checks revolving Python 3.12 and `[odes]` --- noxfile.py | 66 +++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/noxfile.py b/noxfile.py index 7756b57984..27f972d7b7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -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) @@ -111,8 +120,6 @@ def run_unit(session): def run_examples(session): """Run the examples tests for Jupyter notebooks.""" set_environment_variables(PYBAMM_ENV, session=session) - # TODO: remove this when PyBaMM moves to pyproject.toml - session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("-e", ".[all,dev]", silent=False) notebooks_to_test = session.posargs if session.posargs else [] session.run("pytest", "--nbmake", *notebooks_to_test, external=True) @@ -121,8 +128,6 @@ def run_examples(session): @nox.session(name="scripts") def run_scripts(session): """Run the scripts tests for Python scripts.""" - # TODO: remove this when PyBaMM moves to pyproject.toml - session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) set_environment_variables(PYBAMM_ENV, session=session) session.install("-e", ".[all]", silent=False) session.run("python", "run-tests.py", "--scripts") @@ -132,32 +137,30 @@ def run_scripts(session): def set_dev(session): """Install PyBaMM in editable mode.""" set_environment_variables(PYBAMM_ENV, session=session) - # TODO: remove this when PyBaMM moves to pyproject.toml - session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) 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( @@ -184,6 +187,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): @@ -197,8 +203,6 @@ def run_tests(session): def build_docs(session): """Build the documentation and load it in a browser tab, rebuilding on changes.""" envbindir = session.bin - # TODO: remove this when PyBaMM moves to pyproject.toml - session.install("--upgrade", "pip", "setuptools", "wheel", silent=False) session.install("-e", ".[all,docs]", silent=False) session.chdir("docs") # Local development From 5753dbb9fdfda3d46fc6a8b3e08f773948825fc6 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 8 Dec 2023 20:47:49 +0530 Subject: [PATCH 17/18] Update CHANGELOG to reflect Python 3.12 support --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9160e5081..6b44971452 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 a new unary operator, `EvaluateAt`, that evaluates a spatial variable at a given position ([#3573](https://github.com/pybamm-team/PyBaMM/pull/3573)) - Added a method, `insert_reference_electrode`, to `pybamm.lithium_ion.BaseModel` that insert a reference electrode to measure the electrolyte potential at a given position in space and adds new variables that mimic a 3E cell setup. ([#3573](https://github.com/pybamm-team/PyBaMM/pull/3573)) - Serialisation added so models can be written to/read from JSON ([#3397](https://github.com/pybamm-team/PyBaMM/pull/3397)) From 61cc1c897efc82dcf8fc380722ea06645b82e8a4 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sat, 9 Dec 2023 19:53:18 +0530 Subject: [PATCH 18/18] Fix editable installation error --- noxfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/noxfile.py b/noxfile.py index 27f972d7b7..4805bff83c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -168,6 +168,7 @@ def set_dev(session): "-m", "pip", "install", + "-e", ".[all,dev]", external=True, ) @@ -177,6 +178,7 @@ def set_dev(session): "-m", "pip", "install", + "-e", ".[all,dev,jax]", external=True, )