Python #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python | |
on: | |
workflow_dispatch: | |
jobs: | |
macos: | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
architecture: x64 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Build wheels - x86_64 | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: x86_64 | |
args: --release --out dist --sdist -m python/Cargo.toml | |
- name: Install built wheel - x86_64 | |
run: | | |
pip install feathrpiper --no-index --find-links dist --force-reinstall | |
python -c "import feathrpiper" | |
- name: Build wheels - universal2 | |
uses: PyO3/maturin-action@v1 | |
with: | |
args: --release --universal2 --out dist -m python/Cargo.toml | |
- name: Install built wheel - universal2 | |
run: | | |
pip install feathrpiper --no-index --find-links dist --force-reinstall | |
python -c "import feathrpiper" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
windows: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
architecture: x64 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: x64 | |
args: --release --out dist -m python/Cargo.toml | |
- name: Install built wheel | |
run: | | |
pip install feathrpiper --no-index --find-links dist --force-reinstall | |
python -c "import feathrpiper" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
linux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
architecture: x64 | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: x86_64 | |
manylinux: auto | |
args: --release -i "python${{ matrix.python_version }}" --out dist -m python/Cargo.toml | |
- name: Install built wheel | |
run: | | |
pip install feathrpiper --no-index --find-links dist --force-reinstall | |
python -c "import feathrpiper" | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
linux-cross: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: | |
[ | |
{ version: "3.7", abi: "cp37-cp37m" }, | |
{ version: "3.8", abi: "cp38-cp38" }, | |
{ version: "3.9", abi: "cp39-cp39" }, | |
{ version: "3.10", abi: "cp310-cp310" }, | |
{ version: "3.11", abi: "cp311-cp311" }, | |
] | |
target: [aarch64] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build Wheels | |
uses: messense/maturin-action@v1 | |
env: | |
PYO3_CROSS_LIB_DIR: /opt/python/${{ matrix.python.abi }}/lib | |
with: | |
target: ${{ matrix.target }} | |
manylinux: auto | |
args: -i python3.9 --release --out dist -m python/Cargo.toml | |
- uses: uraimo/run-on-arch-action@v2.2.0 | |
name: Install build wheel | |
with: | |
arch: ${{ matrix.target }} | |
distro: ubuntu20.04 | |
githubToken: ${{ github.token }} | |
# Mount the dist directory as /artifacts in the container | |
dockerRunArgs: | | |
--volume "${PWD}/dist:/artifacts" | |
install: | | |
apt update -y | |
apt install -y --no-install-recommends software-properties-common | |
add-apt-repository ppa:deadsnakes/ppa | |
apt update -y | |
PYTHON=python${{ matrix.python.version }} | |
apt install -y $PYTHON $PYTHON-distutils $PYTHON-venv | |
run: | | |
ls -lrth /artifacts | |
PYTHON=python${{ matrix.python.version }} | |
$PYTHON --version | |
$PYTHON -m venv venv | |
source venv/bin/activate | |
pip install --upgrade pip | |
pip install --force-reinstall dist/feathrpiper*.whl | |
cd ~ && python -c 'import feathrpiper' | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [ macos, windows, linux, linux-cross ] | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wheels | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
pip install --upgrade twine | |
twine upload --skip-existing * |