Skip to content

Python Wheels

Python Wheels #28

Workflow file for this run

name: Python Wheels
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v0.1.0)'
required: true
type: string
publish_target:
description: 'Publish built wheels to (none = build only, for testing)'
required: true
default: 'none'
type: choice
options:
- none
- testpypi
- pypi
release:
types: [published]
env:
OVERRIDE_GIT_DESCRIBE: ${{ inputs.version || github.ref_name }}
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-14, windows-2022]
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install cibuildwheel
run: pip install cibuildwheel==2.21.3
- name: Setup ccache
if: runner.os != 'Windows'
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ matrix.os }}-python
- name: Prepare build files
run: python scripts/prepare_wheel_build.py
- name: Build wheels
working-directory: tools/pythonpkg
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: "cp311-* cp312-* cp313-*"
CIBW_SKIP: "*-musllinux* *-manylinux_i686"
CIBW_ARCHS_LINUX: x86_64
CIBW_ARCHS_MACOS: arm64
CIBW_ARCHS_WINDOWS: AMD64
CIBW_BUILD_VERBOSITY: 3
CIBW_BEFORE_ALL_LINUX: >
if command -v yum &>/dev/null; then
yum install -y perl-IPC-Cmd ccache;
elif command -v apk &>/dev/null; then
apk add --no-cache ccache perl;
fi
CIBW_CONTAINER_ENGINE: >
docker; create_args: --volume /home/runner/.cache/ccache:/host/ccache
CIBW_ENVIRONMENT_LINUX: >
SETUPTOOLS_SCM_PRETEND_VERSION=${{ env.OVERRIDE_GIT_DESCRIBE }}
DISTUTILS_C_COMPILER_LAUNCHER=ccache
CCACHE_DIR=/host/ccache
CIBW_ENVIRONMENT_MACOS: >
SETUPTOOLS_SCM_PRETEND_VERSION=${{ env.OVERRIDE_GIT_DESCRIBE }}
DISTUTILS_C_COMPILER_LAUNCHER=ccache
MACOSX_DEPLOYMENT_TARGET=11.0
CIBW_ENVIRONMENT_WINDOWS: >
SETUPTOOLS_SCM_PRETEND_VERSION=${{ env.OVERRIDE_GIT_DESCRIBE }}
CIBW_BEFORE_TEST: ""
CIBW_TEST_COMMAND: python -c "import decidb; print(decidb.__version__)"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: tools/pythonpkg/wheelhouse/*.whl
retention-days: 7
build_sdist:
name: Build source distribution
runs-on: ubuntu-22.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install build tools
run: pip install build setuptools_scm
- name: Prepare build files
run: python scripts/prepare_wheel_build.py --include-jemalloc
- name: Build sdist
working-directory: tools/pythonpkg
run: python -m build --sdist
- name: Verify sdist contents
working-directory: tools/pythonpkg
run: |
tar tzf dist/*.tar.gz | grep sources.list
tar tzf dist/*.tar.gz | grep duckdb_build/ | head -3
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: tools/pythonpkg/dist/*.tar.gz
retention-days: 7
# Manual dry-run target: dispatch with publish_target=testpypi to validate the
# whole pipeline against test.pypi.org without burning a real PyPI version.
publish_testpypi:
name: Publish to TestPyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-22.04
if: github.event_name == 'workflow_dispatch' && inputs.publish_target == 'testpypi'
environment: testpypi
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -la dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
repository-url: https://test.pypi.org/legacy/
# Production publish: fires automatically when a GitHub release is published
# (the draft→publish gate), or manually via publish_target=pypi.
publish_pypi:
name: Publish to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-22.04
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish_target == 'pypi')
environment: pypi
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -la dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
# On a published release, attach the wheels + sdist to the GitHub release page
# (alongside the CLI binaries that DecidBRelease.yml already attached).
attach_to_release:
name: Attach wheels to GitHub release
needs: [build_wheels, build_sdist]
runs-on: ubuntu-22.04
if: github.event_name == 'release'
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Upload wheels + sdist to the release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ github.event.release.tag_name }}" dist/* \
--repo "${{ github.repository }}" --clobber