Skip to content

Wheels

Wheels #41

Workflow file for this run

name: Wheels
on: workflow_dispatch
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-11]
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel"
CIBW_BEFORE_BUILD_LINUX: "pip3 install --upgrade keyrings.alt"
CIBW_ARCHS_LINUX: "x86_64"
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
CIBW_SKIP: "cp36-* pp* *-win32 *musllinux*" # only using manylinux to build
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- if: runner.os == 'Windows'
run: |
echo 'PATH=/c/Python312:/c/Python312/Scripts:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Strawberry/c/bin:$PATH' >> $GITHUB_ENV
echo 'RUSTFLAGS=-Ctarget-feature=+crt-static' >> $GITHUB_ENV
echo 'RUSTFLAGS=-Ctarget-feature=+crt-static' >> $GITHUB_ENV
echo 'CIBW_BEFORE_BUILD=python -m pip install --upgrade pip' >> $GITHUB_ENV
- if: runner.os != 'Linux'
name: Setup env when not using docker
run: |
python -m pip install --upgrade wheel setuptools setuptools-rust
- if: runner.os == 'Linux'
name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: arm64
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.12'
- name: Install cibuildwheel
run: |
# Install cibuildwheel from git for CIBW_ARCHS_LINUX support
python -m pip install cibuildwheel==2.9.0
- if: runner.os == 'Linux'
run: cp -r ./nucypher-core ./nucypher-core-python/nucypher-core
- if: runner.os == 'Linux'
working-directory: ./nucypher-core-python
name: relocate nucypher-core in cargo.toml
run: sed -i 's/..\/nucypher-core/.\/nucypher-core/g' Cargo.toml
- name: Build wheels
working-directory: ./nucypher-core-python
run: |
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v2
with:
path: ./nucypher-core-python/wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.12'
- name: Install setuptools and setuptools-rust
working-directory: ./nucypher-core-python
run: |
python -m pip install --upgrade wheel setuptools setuptools-rust
# Assuming here that the version of the Python bindings
# is matched to the version of the main Rust crate (as it should be at all times),
# and we are running this at a release commit.
- name: Replace the relative path to `nucypher-core` in Cargo.toml with the specific version
working-directory: ./nucypher-core-python
run: python replace_version.py relative-to-published
- name: Build sdist
working-directory: ./nucypher-core-python
run: python setup.py sdist
# Roll back the changes
- name: Replace the specific version of `nucypher-core` in Cargo.toml with the relative path
if: always()
working-directory: ./nucypher-core-python
run: python replace_version.py published-to-relative
- uses: actions/upload-artifact@v2
with:
path: ./nucypher-core-python/dist/*.tar.gz
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: actions/download-artifact@v2
with:
name: artifact
path: wheelhouse
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}