From d81999cd1faedb60d019249ed983e21dfe4f9622 Mon Sep 17 00:00:00 2001 From: Xuehai Pan Date: Fri, 10 May 2024 23:56:55 +0800 Subject: [PATCH] feat(workflows): enable Python 3.12 build (#216) --- .github/workflows/build.yml | 21 +++++++++++++++------ CHANGELOG.md | 2 +- Makefile | 5 +++-- pyproject.toml | 7 +++++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57857770..62497276 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,9 +56,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.8 - 3.11" # sync with requires-python in pyproject.toml + python-version: "3.8 - 3.12" # sync with requires-python in pyproject.toml update-environment: true + - name: Install dependencies + run: python -m pip install --upgrade pip setuptools wheel build + - name: Set __release__ if: | startsWith(github.ref, 'refs/tags/') || @@ -69,9 +72,6 @@ jobs: - name: Print version run: python setup.py --version - - name: Install dependencies - run: python -m pip install --upgrade pip setuptools wheel build - - name: Build sdist and pure-Python wheel run: python -m build env: @@ -120,6 +120,9 @@ jobs: python-version: ${{ matrix.python-version }} update-environment: true + - name: Install dependencies + run: python -m pip install --upgrade pip setuptools wheel build + - name: Set __release__ if: | startsWith(github.ref, 'refs/tags/') || @@ -155,7 +158,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: ["3.9", "3.10", "3.11"] # sync with requires-python in pyproject.toml + python-version: ["3.9", "3.10", "3.11", "3.12"] # sync with requires-python in pyproject.toml fail-fast: false timeout-minutes: 60 steps: @@ -171,6 +174,9 @@ jobs: python-version: ${{ matrix.python-version }} update-environment: true + - name: Install dependencies + run: python -m pip install --upgrade pip setuptools wheel build + - name: Set __release__ if: | startsWith(github.ref, 'refs/tags/') || @@ -249,9 +255,12 @@ jobs: uses: actions/setup-python@v5 if: startsWith(github.ref, 'refs/tags/') with: - python-version: "3.8 - 3.11" # sync with requires-python in pyproject.toml + python-version: "3.8 - 3.12" # sync with requires-python in pyproject.toml update-environment: true + - name: Install dependencies + run: python -m pip install --upgrade pip setuptools wheel build + - name: Set __release__ if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 6489696c..62234c25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- +- Enable CI workflow to build CXX/CUDA extension for Python 3.12 by [@XuehaiPan](https://github.com/XuehaiPan) in [#216](https://github.com/metaopt/torchopt/pull/216). ### Changed diff --git a/Makefile b/Makefile index fd25d8d9..e9099f0c 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ install: install-editable: $(PYTHON) -m pip install --upgrade pip $(PYTHON) -m pip install --upgrade setuptools wheel - $(PYTHON) -m pip install torch numpy pybind11 cmake + $(PYTHON) -m pip install --upgrade pybind11 cmake + $(PYTHON) -m pip install torch numpy USE_FP16=ON TORCH_CUDA_ARCH_LIST=Auto $(PYTHON) -m pip install -vvv --no-build-isolation --editable . install-e: install-editable # alias @@ -114,7 +115,7 @@ addlicense-install: go-install pytest: test-install $(PYTHON) -m pytest --version cd tests && $(PYTHON) -c 'import $(PROJECT_PATH)' && \ - $(PYTHON) -m pytest --verbose --color=yes --durations=0 \ + $(PYTHON) -m pytest --verbose --color=yes \ --cov="$(PROJECT_PATH)" --cov-config=.coveragerc --cov-report=xml --cov-report=term-missing \ $(PYTESTOPTS) . diff --git a/pyproject.toml b/pyproject.toml index 17d14b05..ed93944a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ authors = [ license = { text = "Apache License, Version 2.0" } keywords = [ "PyTorch", - "functorch", + "FuncTorch", "JAX", "Meta-Learning", "Optimizer", @@ -38,6 +38,8 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", @@ -179,7 +181,7 @@ test-command = """ line-length = 100 skip-string-normalization = true # Sync with requires-python -target-version = ["py38", "py39", "py310", "py311"] +target-version = ["py38"] [tool.isort] atomic = true @@ -314,6 +316,7 @@ filterwarnings = [ "error", 'ignore:Explicitly requested dtype float64 requested in .* is not available, and will be truncated to dtype float32\.:UserWarning', 'ignore:jax\.numpy\.DeviceArray is deprecated\. Use jax\.Array\.:DeprecationWarning', + 'ignore:(ast\.Str|ast\.NameConstant|Attribute s) is deprecated and will be removed in Python 3\.14:DeprecationWarning', 'ignore:.*functorch.*deprecate.*:UserWarning', 'ignore:.*Apple Paravirtual device.*:UserWarning', 'ignore:.*NVML.*:UserWarning',