diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c071cdac..acfa98e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,9 +51,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.7 - 3.11" + python-version: "3.7 - 3.12" update-environment: true + - name: Upgrade pip + run: | + python -m pip install --upgrade pip setuptools wheel pybind11 + - name: Set __release__ if: | startsWith(github.ref, 'refs/tags/') || @@ -101,6 +105,10 @@ jobs: python-version: ${{ matrix.python-version }} update-environment: true + - name: Upgrade pip + run: | + python -m pip install --upgrade pip setuptools wheel pybind11 + - name: Set __release__ if: | startsWith(github.ref, 'refs/tags/') || @@ -145,7 +153,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] fail-fast: false timeout-minutes: 45 steps: @@ -161,6 +169,10 @@ jobs: python-version: ${{ matrix.python-version }} update-environment: true + - name: Upgrade pip + run: | + python -m pip install --upgrade pip setuptools wheel pybind11 + - name: Set __release__ if: | startsWith(github.ref, 'refs/tags/') || @@ -216,9 +228,13 @@ jobs: uses: actions/setup-python@v4 if: startsWith(github.ref, 'refs/tags/') with: - python-version: "3.7 - 3.11" + python-version: "3.7 - 3.12" update-environment: true + - name: Upgrade pip + run: | + python -m pip install --upgrade pip setuptools wheel pybind11 + - name: Set __release__ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4f7014e8..fac70128 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -103,7 +103,6 @@ jobs: with: python-version: ${{ matrix.python-version }} update-environment: true - allow-prereleases: true - name: Upgrade pip run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index febd8378..3ecbe237 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Add Python 3.12 support by [@XuehaiPan](https://github.com/XuehaiPan) in [#90](https://github.com/metaopt/optree/pull/90). - Allow passing third-party dependency version from environment variable by [@XuehaiPan](https://github.com/XuehaiPan) in [#80](https://github.com/metaopt/optree/pull/80). ### Changed diff --git a/include/utils.h b/include/utils.h index 37ea7a7d..950a02b4 100644 --- a/include/utils.h +++ b/include/utils.h @@ -18,8 +18,12 @@ limitations under the License. #pragma once #include + +#if PY_VERSION_HEX < 0x30C00F0 // Python 3.12.0 +#include // PyMemberDef +#endif + #include -#include // PyMemberDef #include #include diff --git a/pyproject.toml b/pyproject.toml index 0ce11d04..a5b4d847 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,7 +105,7 @@ test-command = """make -C "{project}" test PYTHON=python""" safe = true line-length = 100 skip-string-normalization = true -target-version = ["py37", "py38", "py39", "py310", "py311"] +target-version = ["py37", "py38", "py39", "py310", "py311", "py312"] [tool.isort] atomic = true diff --git a/src/treespec/treespec.cpp b/src/treespec/treespec.cpp index fba5a159..5dfc1924 100644 --- a/src/treespec/treespec.cpp +++ b/src/treespec/treespec.cpp @@ -17,9 +17,6 @@ limitations under the License. #include "include/treespec.h" -#include -#include // PyMemberDef - namespace optree { ssize_t PyTreeSpec::GetNumLeaves() const {