Skip to content

Commit

Permalink
fix: python publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dirvine committed Nov 30, 2024
1 parent 1714681 commit a08c43b
Show file tree
Hide file tree
Showing 12 changed files with 694 additions and 983 deletions.
261 changes: 234 additions & 27 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: Build and Publish Python Package
name: Build and Publish self_encryption Python Package

on:
push:
tags:
- 'v*'

env:
PYTHON_VERSION: "3.10"
PACKAGE_NAME: "self_encryption"

# Add top-level permissions block
permissions:
id-token: write
Expand All @@ -30,12 +34,12 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
args: --release --out dist -i python${{ matrix.python-version }}
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-macos-${{ matrix.target }}-py${{ matrix.python-version }}
path: dist/*.whl
if-no-files-found: error

Expand All @@ -58,47 +62,240 @@ jobs:
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
args: --release --out dist
args: --release --out dist -i python${{ matrix.python-version }}
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-windows-${{ matrix.target }}-py${{ matrix.python-version }}
path: dist/*.whl
if-no-files-found: error

linux:
runs-on: ubuntu-latest
# Add permissions to job
permissions:
id-token: write
contents: read
strategy:
matrix:
target: [x86_64, i686]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
target: [x86_64]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --user cffi
python -m pip install --user patchelf
architecture: x64
- name: Build wheels
uses: PyO3/maturin-action@v1
env:
PYTHON_VERSION: ${{ matrix.python-version }}
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist
sccache: 'true'
args: --release --out dist -i python${{ matrix.python-version }}
- name: Install built wheel
if: matrix.target == 'x86_64'
run: |
# List all wheels to debug
echo "Available wheels:"
ls -la dist/
pip install -U pip pytest click>=8.0.0
pip install --find-links dist/ ${{ env.PACKAGE_NAME }}
pytest -v
- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
path: dist/*.whl
if-no-files-found: error
name: wheels-linux-${{ matrix.target }}-py${{ matrix.python-version }}
path: dist

# linux-cross:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# target: [aarch64, armv7, s390x, ppc64le, ppc64]
# python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
# steps:
# - uses: actions/checkout@v3
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# - name: Build wheels
# uses: PyO3/maturin-action@v1
# env:
# PYO3_CROSS_PYTHON_VERSION: ${{ matrix.python-version }}
# PYO3_CROSS: "1"
# PYTHON_VERSION: ${{ matrix.python-version }}
# with:
# target: ${{ matrix.target }}
# manylinux: auto
# args: --release --out dist -i python${{ matrix.python-version }}
# sccache: 'true'
# docker-options: >-
# --platform ${{ matrix.target == 'armv7' && 'linux/arm/v7' ||
# matrix.target == 'aarch64' && 'linux/arm64' ||
# matrix.target == 's390x' && 'linux/s390x' ||
# matrix.target == 'ppc64le' && 'linux/ppc64le' ||
# 'linux/amd64' }}
# - uses: uraimo/[email protected]
# if: matrix.target != 'ppc64'
# name: Install built wheel
# with:
# arch: ${{ matrix.target }}
# distro: ubuntu_latest
# githubToken: ${{ github.token }}
# install: |
# apt-get update
# apt-get install -y --no-install-recommends python3 python3-pip python3-venv
# pip3 install -U pip pytest click>=8.0.0
# run: |
# # List all wheels to debug
# echo "Available wheels:"
# ls -la dist/

# # Install using find-links to handle platform tags correctly
# pip3 install --find-links dist/ ${{ env.PACKAGE_NAME }}
# pytest -v
# - name: Upload wheels
# uses: actions/upload-artifact@v4
# with:
# name: wheels-linux-cross-${{ matrix.target }}-py${{ matrix.python-version }}
# path: dist

musllinux:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- i686-unknown-linux-musl
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
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
env:
PYO3_CROSS_PYTHON_VERSION: ${{ matrix.python-version }}
PYO3_CROSS: "1"
with:
target: ${{ matrix.target }}
manylinux: musllinux_1_2
args: --release --out dist -i python${{ matrix.python-version }}
- name: Install built wheel
if: matrix.target == 'x86_64-unknown-linux-musl'
uses: addnab/docker-run-action@v3
with:
image: alpine:latest
options: -v ${{ github.workspace }}:/io -w /io
run: |
# Install system dependencies
apk add --no-cache \
python3 \
py3-pip \
gcc \
musl-dev \
python3-dev \
rust \
cargo \
openssl-dev \
pkgconfig
# Create and activate virtual environment
python3 -m venv /venv
. /venv/bin/activate
# Install Python dependencies
pip install --upgrade pip wheel setuptools
pip install pytest click>=8.0.0
# Install in development mode
cd /io
pip install -e .
# Run tests
python -m pytest -v
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-musllinux-${{ matrix.target }}-py${{ matrix.python-version }}
path: dist

# musllinux-cross:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# platform:
# - target: aarch64-unknown-linux-musl
# arch: aarch64
# platform: linux/arm64
# - target: armv7-unknown-linux-musleabihf
# arch: armv7
# platform: linux/arm/v7
# python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
# steps:
# - uses: actions/checkout@v3
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
# - uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# - name: Build wheels
# uses: PyO3/maturin-action@v1
# env:
# PYO3_CROSS_PYTHON_VERSION: ${{ matrix.python-version }}
# PYO3_CROSS: "1"
# with:
# target: ${{ matrix.platform.target }}
# manylinux: musllinux_1_2
# args: --release --out dist -i python${{ matrix.python-version }}
# sccache: 'true'
# docker-options: "--platform ${{ matrix.platform.platform }}"
# - uses: uraimo/run-on-arch-action@master
# name: Install built wheel
# with:
# arch: ${{ matrix.platform.arch }}
# distro: alpine_latest
# githubToken: ${{ github.token }}
# install: |
# apk add --no-cache \
# python3 \
# py3-pip \
# gcc \
# musl-dev \
# python3-dev \
# rust \
# cargo \
# openssl-dev \
# pkgconfig
# run: |
# # Create and activate virtual environment
# python3 -m venv /venv
# . /venv/bin/activate

# # Install Python dependencies
# pip install --upgrade pip wheel setuptools
# pip install pytest click>=8.0.0

# # Install in development mode
# cd /io
# pip install -e .

# # Run tests
# python -m pytest -v
# - name: Upload wheels
# uses: actions/upload-artifact@v4
# with:
# name: wheels-musllinux-cross-${{ matrix.platform.target }}-py${{ matrix.python-version }}
# path: dist


sdist:
runs-on: ubuntu-latest
Expand All @@ -114,9 +311,9 @@ jobs:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: wheels-sdist-py${{ env.PYTHON_VERSION }}
path: dist/*.tar.gz
if-no-files-found: error

Expand All @@ -131,13 +328,23 @@ jobs:
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
name: wheels-*
path: dist

# Add additional steps to download each artifact type
- uses: actions/download-artifact@v3
with:
name: wheels-sdist-py${{ env.PYTHON_VERSION }}
path: dist

# We might need multiple download steps or a different approach
# to combine all artifacts

- name: Display structure of downloaded files
run: ls -R dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
verbose: true
print-hash: true
print-hash: true
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ version = "0.32.4"

[features]
default = []
python = ["pyo3/extension-module"]
python = [
"pyo3/extension-module",
"serde_json"
]

[dependencies]
aes = "~0.8.1"
Expand All @@ -27,7 +30,8 @@ num_cpus = "1.13.0"
itertools = "~0.10.0"
tempfile = "3.6.0"
xor_name = "5.0.0"
pyo3 = { version = "0.19", optional = true, features = ["extension-module"] }
pyo3 = { version = "=0.20.3", optional = true, features = ["extension-module"] }
serde_json = { version = "1.0", optional = true }

[dependencies.brotli]
version = "~3.3.0"
Expand Down Expand Up @@ -57,6 +61,7 @@ features = ["rt"]
[dev-dependencies]
criterion = "~0.3"
docopt = "~0.9.0"
clap = { version = "4.4", features = ["derive"] }

[dev-dependencies.tokio]
version = "1.34.0"
Expand Down
Loading

0 comments on commit a08c43b

Please sign in to comment.