Skip to content

Commit

Permalink
Support Python 3.12 (#5743)
Browse files Browse the repository at this point in the history
### Description
Close #5680

### Motivation and Context
- Add Python 3.12 support.

---------

Signed-off-by: isdanni <leedanni@gmail.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
  • Loading branch information
isdanni and justinchuby committed Jan 23, 2024
1 parent ae749f3 commit 3a39b0b
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 78 deletions.
6 changes: 6 additions & 0 deletions .azure-pipelines/Linux-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
vmImage: 'Ubuntu-20.04'
strategy:
matrix:
py312-internal-protobuf:
python.version: '3.12'
onnx_ml: 1
build_type: 'Release'
documentation: 0
protobuf_type: 'Internal'
py311-ml-debug-external-protobuf:
python.version: '3.11'
onnx_ml: 1
Expand Down
6 changes: 6 additions & 0 deletions .azure-pipelines/MacOS-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ jobs:
vmImage: 'macOS-11'
strategy:
matrix:
py312-internal-protobuf:
python.version: '3.12'
onnx_ml: 1
build_type: 'Release'
documentation: 0
protobuf_type: 'Internal'
py311-external-protobuf:
python.version: '3.11'
onnx_ml: 0
Expand Down
6 changes: 6 additions & 0 deletions .azure-pipelines/Windows-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ jobs:
vmImage: 'windows-2019'
strategy:
matrix:
py312-internal-protobuf:
python.version: '3.12'
onnx_ml: 1
build_type: 'Release'
documentation: 0
protobuf_type: 'Internal'
py311-ml-external-protobuf:
python.version: '3.11'
onnx_ml: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manylinux/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if [ "$(uname -m)" == "aarch64" ]; then
PIP_INSTALL_COMMAND="$PY_VERSION -m pip install --no-cache-dir -q"
PYTHON_COMMAND="$PY_VERSION"
else
declare -A python_map=( ["3.8"]="cp38-cp38" ["3.9"]="cp39-cp39" ["3.10"]="cp310-cp310" ["3.11"]="cp311-cp311")
declare -A python_map=( ["3.8"]="cp38-cp38" ["3.9"]="cp39-cp39" ["3.10"]="cp310-cp310" ["3.11"]="cp311-cp311" ["3.12"]="cp312-cp312")
PY_VER=${python_map[$PY_VERSION]}
PIP_INSTALL_COMMAND="/opt/python/${PY_VER}/bin/pip install --no-cache-dir -q"
PYTHON_COMMAND="/opt/python/${PY_VER}/bin/python"
Expand Down
31 changes: 4 additions & 27 deletions .github/workflows/release_linux_aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [cp38-cp38, cp39-cp39, cp310-cp310, cp311-cp311]
python-version: [cp38-cp38, cp39-cp39, cp310-cp310, cp311-cp311, cp312-cp312]
env:
# setting up python and docker image
py: /opt/python/${{ matrix.python-version }}/bin/python
Expand Down Expand Up @@ -98,43 +98,20 @@ jobs:
pytest && \
deactivate'
- name: Verify ONNX with the minimum supported numpy
if: ${{ always() }}
run: |
# only difference is numpy version
if [[ "${{ matrix.python-version }}" == "cp38-cp38" || "${{ matrix.python-version }}" == "cp39-cp39" ]]; then
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '\
source .env/bin/activate && \
python -m pip uninstall -y onnx numpy && python -m pip install numpy==1.16.6 && \
python -m pip install dist/*manylinux2014_aarch64.whl && \
pytest && \
deactivate'
else
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '\
source .env/bin/activate && \
python -m pip uninstall -y onnx numpy && python -m pip install numpy==1.23.2 && \
python -m pip install dist/*manylinux2014_aarch64.whl && \
pytest && \
deactivate'
fi
- name: Verify ONNX with the minimum supported protobuf (from requirements.txt)
- name: Verify ONNX with the minimumly supported packages
if: ${{ always() }}
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '\
source .env/bin/activate && \
python -m pip uninstall -y onnx && python -m pip install protobuf==3.20.2 && \
python -m pip uninstall -y onnx && python -m pip install -r requirements-min.txt && \
python -m pip install dist/*manylinux2014_aarch64.whl && \
pytest && \
deactivate'
- name: Verify ONNX with ONNX Runtime PyPI package
if: matrix.python-version != 'cp312-cp312'
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/release_linux_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
architecture: ['x64']

steps:
Expand All @@ -32,7 +32,7 @@ jobs:
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Build manylinux2014_x86_64
uses: docker://quay.io/pypa/manylinux2014_x86_64:latest@sha256:085b7c2c1bcb45b936e5478fe24a5142b0519e242a0104142fd50d569d6cb922
uses: docker://quay.io/pypa/manylinux2014_x86_64:latest
with:
entrypoint: bash
args: .github/workflows/manylinux/entrypoint.sh ${{ matrix.python-version }} manylinux2014_x86_64 ${{ github.event_name }}
Expand Down Expand Up @@ -75,33 +75,22 @@ jobs:
python -m pip install dist/*manylinux2014_x86_64.whl
pytest
- name: Verify ONNX with the minimum supported numpy
if: ${{ always() }}
run: |
if [[ "${{ matrix.python-version }}" == "3.8" || "${{ matrix.python-version }}" == "3.9" ]]; then
export minimum_numpy_version=1.16.6
else
export minimum_numpy_version=1.23.2
fi
python -m pip uninstall -y numpy onnx && python -m pip install numpy==$minimum_numpy_version
python -m pip install dist/*manylinux2014_x86_64.whl
pytest
- name: Verify ONNX with the latest protobuf
if: ${{ always() }}
run: |
python -m pip uninstall -y protobuf onnx && python -m pip install protobuf
python -m pip install dist/*manylinux2014_x86_64.whl
pytest
- name: Verify ONNX with the minimum supported protobuf (from requirements.txt)
- name: Verify ONNX with the minimumly supported packages
if: ${{ always() }}
run: |
python -m pip uninstall -y protobuf onnx && python -m pip install protobuf==3.20.2
python -m pip uninstall -y numpy protobuf onnx && python -m pip install -r requirements-min.txt
python -m pip install dist/*manylinux2014_x86_64.whl
pytest
- name: Verify ONNX with ONNX Runtime PyPI package
if: matrix.python-version != '3.12'
run: |
python -m pip uninstall -y protobuf numpy && python -m pip install -q -r requirements-release.txt
python -m pip install -q onnxruntime
Expand Down
19 changes: 4 additions & 15 deletions .github/workflows/release_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
host-architecture: ['x64']
target-architecture: ['x86_64', 'universal2']

Expand Down Expand Up @@ -92,29 +92,17 @@ jobs:
for file in dist/*.whl; do python -m pip install --upgrade $file; done
pytest
- name: Verify ONNX with the minimum supported numpy
if: ${{ always() }}
run: |
if [[ "${{ matrix.python-version }}" == "3.8" || "${{ matrix.python-version }}" == "3.9" ]]; then
export minimum_numpy_version=1.16.6
else
export minimum_numpy_version=1.23.2
fi
python -m pip uninstall -y numpy onnx && python -m pip install numpy==$minimum_numpy_version
for file in dist/*.whl; do python -m pip install --upgrade $file; done
pytest
- name: Verify ONNX with the latest protobuf
if: ${{ always() }}
run: |
python -m pip uninstall -y protobuf onnx && python -m pip install protobuf
for file in dist/*.whl; do python -m pip install --upgrade $file; done
pytest
- name: Verify ONNX with the minimum supported protobuf (from requirements.txt)
- name: Verify ONNX with the minimumly supported packages
if: ${{ always() }}
run: |
python -m pip uninstall -y protobuf onnx && python -m pip install protobuf==3.20.2
python -m pip uninstall -y numpy protobuf onnx && python -m pip install -r requirements-min.txt
for file in dist/*.whl; do python -m pip install --upgrade $file; done
pytest
Expand All @@ -135,6 +123,7 @@ jobs:
pytest
- name: Verify ONNX with ONNX Runtime PyPI package
if: matrix.python-version != '3.12'
run: |
python -m pip uninstall -y protobuf numpy && python -m pip install -q -r requirements-release.txt
python -m pip install -q onnxruntime
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/release_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
architecture: ['x64', 'x86']
steps:
- name: Checkout ONNX
Expand Down Expand Up @@ -99,19 +99,6 @@ jobs:
python -m pip uninstall -y numpy onnx && python -m pip install numpy
Get-ChildItem -Path dist/*.whl | foreach {python -m pip install --upgrade $_.fullname}
pytest
# TODO: Remove if conditions in all release CIs after the minimum supported numpy is upgraded to 1.23.2 or higher
- name: Verify ONNX with the minimum supported numpy
if: ${{ always() }}
run: |
cd onnx
if ('${{ matrix.python-version }}' -eq '3.8' -Or '${{ matrix.python-version }}' -eq '3.9') {
$minimum_numpy_version="1.16.6"
} else {
$minimum_numpy_version="1.23.2"
}
python -m pip uninstall -y numpy onnx && python -m pip install numpy==$minimum_numpy_version
Get-ChildItem -Path dist/*.whl | foreach {python -m pip install --upgrade $_.fullname}
pytest
- name: Verify ONNX with the latest protobuf
if: ${{ always() }}
Expand All @@ -121,15 +108,16 @@ jobs:
Get-ChildItem -Path dist/*.whl | foreach {python -m pip install --upgrade $_.fullname}
pytest
- name: Verify ONNX with the minimum supported protobuf (from requirements.txt)
- name: Verify ONNX with the minimumly supported packages
if: ${{ always() }}
run: |
cd onnx
python -m pip uninstall -y protobuf onnx && python -m pip install protobuf==3.20.2
python -m pip uninstall -y protobuf numpy onnx && python -m pip install -r requirements-min.txt
Get-ChildItem -Path dist/*.whl | foreach {python -m pip install --upgrade $_.fullname}
pytest
- name: Verify ONNX with ONNX Runtime PyPI package
if: matrix.python-version != '3.12'
run: |
cd onnx
python -m pip uninstall -y protobuf numpy && python -m pip install -q -r requirements-release.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/win_no_exception_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
architecture: ['x64']
steps:
- name: Checkout ONNX
Expand Down
7 changes: 7 additions & 0 deletions requirements-min.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Minimum package versions that ONNX supports
protobuf==3.20.2; python_version<"3.12"
protobuf==4.25.1; python_version>="3.12"
numpy==1.16.6; python_version<"3.10"
numpy==1.23.2; python_version=="3.10"
numpy==1.23.2; python_version=="3.11"
numpy==1.26.0; python_version>="3.12"
6 changes: 4 additions & 2 deletions requirements-release.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
build
ipython
nbval
numpy==1.24.3
numpy==1.24.3; python_version<"3.12"
numpy==1.26.0; python_version>="3.12"
parameterized
protobuf==4.21.12
protobuf==4.21.12; python_version<"3.12"
protobuf==4.25.1; python_version>="3.12"
pytest
pytest-cov
pytest-xdist
Expand Down

0 comments on commit 3a39b0b

Please sign in to comment.