Skip to content

Commit

Permalink
Merge pull request #704 from ayys/run-on-m1-with-python-3.11
Browse files Browse the repository at this point in the history
Support for python 3.11
  • Loading branch information
ayys authored Apr 18, 2023
2 parents 1f2f0a5 + f4b595e commit bf419ad
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 115 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:

strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10"]
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target:
- id: 'linux-amd64'
os: 'ubuntu-18.04'
os: 'ubuntu-latest'
target-name: 'x86_64-unknown-linux-gnu'
rust-toolchain: 'stable'
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz'
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
maturin list-python
PYTHON_INTERPRETER=$(maturin list-python | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
PYTHON_INTERPRETER=$(maturin list-python 2>&1 | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
echo "Selected interpreter: ${PYTHON_INTERPRETER}"
just build-all "${{ matrix.target.target-name }}"
Expand All @@ -157,7 +157,7 @@ jobs:
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
maturin list-python
PYTHON_INTERPRETER=$(maturin list-python | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
PYTHON_INTERPRETER=$(maturin list-python 2>&1 | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
echo "Selected interpreter: ${PYTHON_INTERPRETER}"
just build-all-wheels "${PYTHON_INTERPRETER}" "${{ matrix.target.target-name }}"
just build-any-wheel
Expand All @@ -178,7 +178,7 @@ jobs:
release:
name: Release

runs-on: ubuntu-18.04
runs-on: ubuntu-latest

needs: [build]

Expand Down Expand Up @@ -206,13 +206,13 @@ jobs:
- name: Set current Python version
shell: bash
run: |
echo "3.9" > .python-version
echo "3.11" > .python-version
- name: Set up Python ${{ matrix.python }} (amd64)
if: matrix.target.id != 'linux-aarch64'
uses: actions/setup-python@v1
with:
python-version: 3.9
python-version: 3.11

- name: Set up Python ${{ matrix.python }} (aarch64)
if: matrix.target.id == 'linux-aarch64'
Expand All @@ -222,7 +222,7 @@ jobs:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv install --list | grep '^ 3.9' | tail -n 1 | tr -d '[:space:]' > .python-version
pyenv install --list | grep '^ 3.11' | tail -n 1 | tr -d '[:space:]' > .python-version
pyenv install --skip-existing "$(cat .python-version)"
# Caching is disabled because it interferes with artifact creation
Expand Down
53 changes: 37 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@ on:
branches:
- '**'

# Allow one concurrent deployment
concurrency:
group: ${{ github.ref }}-test
cancel-in-progress: true

jobs:
test:
name: Build and Test

strategy:
matrix:
python: ["3.7", "3.8", "3.9", "3.10"]
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
target:
- id: 'linux-amd64'
os: 'ubuntu-18.04'
os: 'ubuntu-latest'
target-name: 'x86_64-unknown-linux-gnu'
rust-toolchain: 'stable'
llvm_url: 'https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz'
Expand All @@ -43,7 +48,7 @@ jobs:
rust-toolchain: 'stable'
# llvm_url: 'https://github.com/wasmerio/llvm-custom-builds/releases/download/11.x/windows-amd64.tar.gz'
llvm_choco_version: 13.0.0
fail-fast: true
fail-fast: false

runs-on: ${{ matrix.target.os }}

Expand All @@ -67,7 +72,9 @@ jobs:
target: ${{ matrix.target.target-name }}

# Caching is disabled because it interferes with artifact creation
#- uses: Swatinem/rust-cache@v1
# - uses: Swatinem/rust-cache@v2
# with:
# shared-key: "rust-cache"

- name: Set current Python version
shell: bash
Expand All @@ -76,9 +83,10 @@ jobs:
- name: Set up Python ${{ matrix.python }} (amd64)
if: matrix.target.id != 'linux-aarch64'
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: x64

- name: Set up Python ${{ matrix.python }} (aarch64)
if: matrix.target.id == 'linux-aarch64'
Expand All @@ -91,6 +99,21 @@ jobs:
pyenv install --list | grep '^ ${{ matrix.python }}' | tail -n 1 | tr -d '[:space:]' > .python-version
pyenv install --skip-existing "$(cat .python-version)"
- name: Validate python version
run: |
$pythonVersionFull = (python --version)
$pythonVersion = $pythonVersionFull -replace '\.(\d+)$',''
if ("Python ${{ matrix.python }}" -ne "$pythonVersion"){
Write-Host "The current version is $pythonVersion; expected version is ${{ matrix.python }}"
exit 1
}
$pythonVersion
shell: pwsh
- name: Print python version (verbose)
run: |
python -VV
shell: pwsh

- name: Install LLVM (Choco - Windows)
if: matrix.target.llvm_choco_version
shell: bash
Expand All @@ -99,10 +122,7 @@ jobs:
cd 'C:\Program Files\LLVM\'
LLVM_DIR=$(pwd)
echo "LLVM_SYS_120_PREFIX=${LLVM_DIR}" >> $GITHUB_ENV
- name: Install LLVM (macOS Apple Silicon)
if: matrix.target.os == 'macos-latest' && !matrix.target.llvm_url
run: |
brew install llvm
- name: Install LLVM
if: matrix.target.llvm_url
shell: bash
Expand Down Expand Up @@ -143,14 +163,15 @@ jobs:
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
just prelude
- name: Compile the library
shell: bash
run: |
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
maturin list-python
PYTHON_INTERPRETER=$(maturin list-python | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
PYTHON_INTERPRETER=$(maturin list-python 2>&1 | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
echo "Selected interpreter: ${PYTHON_INTERPRETER}"
just build-all "${{ matrix.target.target-name }}"
Expand All @@ -169,7 +190,7 @@ jobs:
export PATH="$HOME/.pyenv/versions/$(cat .python-version)/bin:$PATH"
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
maturin list-python
PYTHON_INTERPRETER=$(maturin list-python | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
PYTHON_INTERPRETER=$(maturin list-python 2>&1 | grep -o "CPython $(cat .python-version | grep -o -E '^[^\.]+\.[^\.]+').* at .*" | cut -d' ' -f 4 | tr '\\' '/')
echo "Selected interpreter: ${PYTHON_INTERPRETER}"
just build-all-wheels "${PYTHON_INTERPRETER}" "${{ matrix.target.target-name }}"
just build-any-wheel
Expand All @@ -190,7 +211,7 @@ jobs:
prerelease:
name: Pre-Release

runs-on: ubuntu-18.04
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/prepare-')

needs: [test]
Expand All @@ -212,13 +233,13 @@ jobs:
- name: Set current Python version
shell: bash
run: |
echo "3.9" > .python-version
echo "3.11" > .python-version
- name: Set up Python ${{ matrix.python }} (amd64)
if: matrix.target.id != 'linux-aarch64'
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: 3.11

- name: Set up Python ${{ matrix.python }} (aarch64)
if: matrix.target.id == 'linux-aarch64'
Expand All @@ -228,7 +249,7 @@ jobs:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv install --list | grep '^ 3.9' | tail -n 1 | tr -d '[:space:]' > .python-version
pyenv install --list | grep '^ 3.11' | tail -n 1 | tr -d '[:space:]' > .python-version
pyenv install --skip-existing "$(cat .python-version)"
# Caching is disabled because it interferes with artifact creation
Expand Down
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ prelude:
pip3 install virtualenv
virtualenv .env
if test -d .env/bin/; then source .env/bin/activate; else source .env/Scripts/activate; fi
pip3 install maturin==0.12.20 pytest pytest-benchmark twine pdoc
pip3 install maturin==0.14.17 pytest pytest-benchmark twine pdoc

which maturin
maturin --version
Expand Down Expand Up @@ -65,7 +65,7 @@ build package='api' rust_target=`rustc -vV | awk '/^host/ { print $2 }'`:

cd packages/{{package}}/

maturin develop --binding-crate pyo3 --release --strip --cargo-extra-args="${build_args}"
maturin develop --binding-crate pyo3 --release --strip

# Build all the wheels.
build-all-wheels python_version rust_target:
Expand Down Expand Up @@ -108,7 +108,7 @@ build-wheel package python_version rust_target:

cd packages/{{package}}

maturin build --bindings pyo3 --release --target "{{ rust_target }}" --strip --cargo-extra-args="${build_args}" --interpreter "{{python_version}}"
maturin build --bindings pyo3 --release --target "{{ rust_target }}" --strip --interpreter "{{python_version}}"

# Create a distribution of wasmer that can be installed anywhere (it will fail on import)
build-any-wheel:
Expand Down
22 changes: 0 additions & 22 deletions packages/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,3 @@ cfg-if = "1.0"

[build-dependencies]
pyo3-build-config = "0.15"

[package.metadata.maturin]
classifier = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Rust",
"Topic :: Software Development",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Interpreters",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

[package.metadata.maturin.project-url]
"Source Code" = "https://github.com/wasmerio/wasmer-python/"
"Bug Tracker" = "https://github.com/wasmerio/wasmer-python/issues"
"Documentation" = "https://github.com/wasmerio/wasmer-python/"
28 changes: 28 additions & 0 deletions packages/api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
edition = "2018"

[build-system]
requires = ["maturin>=0.14,<0.15"]
build-backend = "maturin"

[tool.maturin.metadata]
category = ["Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Rust",
"Topic :: Software Development",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Interpreters",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"]


[tool.maturin.project-url]
"Source Code" = "https://github.com/wasmerio/wasmer-python/"
"Bug Tracker" = "https://github.com/wasmerio/wasmer-python/issues"
"Documentation" = "https://github.com/wasmerio/wasmer-python/"
22 changes: 0 additions & 22 deletions packages/compiler-cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,3 @@ crate-type = ["cdylib"]
wasmer-engines = { path = "../engines/" }
wasmer-compiler-cranelift = "2.1.1"
pyo3 = { version = "0.14", features = ["extension-module"] }

[package.metadata.maturin]
classifier = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Rust",
"Topic :: Software Development",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Interpreters",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

[package.metadata.maturin.project-url]
"Source Code" = "https://github.com/wasmerio/wasmer-python/"
"Bug Tracker" = "https://github.com/wasmerio/wasmer-python/issues"
"Documentation" = "https://github.com/wasmerio/wasmer-python/"
28 changes: 28 additions & 0 deletions packages/compiler-cranelift/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
edition = "2018"

[build-system]
requires = ["maturin>=0.14,<0.15"]
build-backend = "maturin"

[tool.maturin.metadata]
category = ["Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Rust",
"Topic :: Software Development",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Interpreters",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"]


[tool.maturin.project-url]
"Source Code" = "https://github.com/wasmerio/wasmer-python/"
"Bug Tracker" = "https://github.com/wasmerio/wasmer-python/issues"
"Documentation" = "https://github.com/wasmerio/wasmer-python/"
22 changes: 0 additions & 22 deletions packages/compiler-llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,3 @@ crate-type = ["cdylib"]
wasmer-engines = { path = "../engines/" }
wasmer-compiler-llvm = "2.1.1"
pyo3 = { version = "0.14", features = ["extension-module"] }

[package.metadata.maturin]
classifier = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Rust",
"Topic :: Software Development",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Interpreters",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

[package.metadata.maturin.project-url]
"Source Code" = "https://github.com/wasmerio/wasmer-python/"
"Bug Tracker" = "https://github.com/wasmerio/wasmer-python/issues"
"Documentation" = "https://github.com/wasmerio/wasmer-python/"
Loading

0 comments on commit bf419ad

Please sign in to comment.