Skip to content

TMP: release python 3.12 packages for windows #2

TMP: release python 3.12 packages for windows

TMP: release python 3.12 packages for windows #2

Workflow file for this run

name: release-tmp
on:
push:
branches:
- tmp
release:
types: [created]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
python-publish:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v1
- name: Install latest stable Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Set up Python 3.7
id: setup-python-3-7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Set up Python 3.8
id: setup-python-3-8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Set up Python 3.9
id: setup-python-3-9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Set up Python 3.10
id: setup-python-3-10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Set up Python 3.11
id: setup-python-3-11
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Set up Python 3.12
id: setup-python-3-12
uses: actions/setup-python@v2
with:
python-version: "3.12"
- name: Build wheels (unix)
if: matrix.os != 'windows-latest'
uses: messense/maturin-action@v1
with:
command: build
manylinux: 2014
args: --release --strip --features pybindings -i python3.7 python3.8 python3.9 python3.10 python3.11 python3.12
- name: Build wheels (windows)
if: matrix.os == 'windows-latest'
uses: messense/maturin-action@v1
with:
command: build
args: --release --strip --features pybindings -i C:\hostedtoolcache\windows\Python\${{ steps.setup-python-3-12.outputs.python-version }}\x64\python3.exe
# For some reason, manylinux builds create wheels owned by the root user,
# which breaks our attempts to add the license file below.
- name: Fix wheel ownership on linux
if: matrix.os == 'ubuntu-latest'
run: sudo chown -R runner:docker target
- name: Cross-build wheels for Apple Silicon
if: matrix.os == 'macos-latest'
uses: messense/maturin-action@v1
with:
target: aarch64-apple-darwin
command: build
args: --release --strip --features pybindings -i python3.7 python3.8 python3.9 python3.10 python3.11 python3.12
- name: Build universal2 wheels
if: matrix.os == 'macos-latest'
uses: messense/maturin-action@v1
with:
command: build
args: --release --strip --features pybindings --universal2 -i python3.7 python3.8 python3.9 python3.10 python3.11 python3.12
- name: List wheels (unix)
if: matrix.os != 'windows-latest'
run: ls -l ./target/wheels/
- name: List wheels (windows)
if: matrix.os == 'windows-latest'
run: dir target\wheels\
- name: generate license file
run: |
cargo install cargo-about
cargo about generate --features=pybindings about.hbs > LICENSE.html
ls -l LICENSE.html
wc -l LICENSE.html
- name: Add LICENSE.html to all wheels (unix)
if: matrix.os != 'windows-latest'
run: |
for wheel in target/wheels/*.whl; do
zip -ur $wheel LICENSE.html
done
- name: Add LICENSE.html to all wheels (windows)
if: matrix.os == 'windows-latest'
run: |
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null
Get-ChildItem "target\wheels\" -Filter *.whl |
Foreach-Object {
$zip = [System.IO.Compression.ZipFile]::Open($_.FullName, "Update")
$licenseFile = [System.IO.Path]::GetFileName("LICENSE.html")
[System.IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip, "LICENSE.html", $licenseFile, "Optimal") | Out-Null
$zip.Dispose()
}
- name: Save artifact with wheels for ${{ matrix.os }}
uses: actions/upload-artifact@v2
with:
name: wheels-${{ matrix.os }}
path: ./target/wheels/
- name: Test install wheels (unix)
if: matrix.os != 'windows-latest'
run: |
for i in target/wheels/*.whl; do
echo "Running: pip install $i ..."
pip install "$i" || echo "WARNING: unable to install $i"
echo "Testing if we can import constriction and numpy ..."
python -c 'import constriction; import numpy; print(constriction.__file__)' || echo "WARNING: unable to import constriction or numpy ($i)"
echo "Running: pip uninstall -y constriction numpy"
pip uninstall -y constriction numpy
echo
done
- name: Test install wheels (windows)
if: matrix.os == 'windows-latest'
run: |
$wheels = Get-ChildItem "target\wheels\"
foreach ($wheel in $wheels){
echo "Running: pip install $($wheel.FullName) ..."
try {
pip install "$($wheel.FullName)"
} catch {
echo "WARNING: unable to install $($wheel.FullName)"
}
echo "Testing if we can import constriction and numpy ..."
try {
python -c 'import constriction; import numpy; print(constriction.__file__)'
} catch {
echo "WARNING: unable to import constriction or numpy ($($wheel.FullName))"
}
echo "Running: pip uninstall -y constriction numpy ..."
pip uninstall -y constriction numpy
echo ""
}
- name: Install Python dependencies (for twine)
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install
- name: Publish wheels (unix)
if: matrix.os != 'windows-latest' && github.event_name == 'release'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI }}
run: |
poetry run twine upload target/wheels/*.whl
- name: Publish wheels (windows)
if: matrix.os == 'windows-latest' && github.event_name == 'release'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI }}
run: |
$wheels = Get-ChildItem "target\wheels\"
foreach ($wheel in $wheels){
echo "Uploading $($wheel.FullName)"
poetry run twine upload "$($wheel.FullName)"
}