Skip to content

Commit

Permalink
Merge pull request #135 from benjeffery/build-wheels-docker
Browse files Browse the repository at this point in the history
Build wheels in docker
  • Loading branch information
benjeffery authored Feb 5, 2025
2 parents 89924d7 + c2fe255 commit 8b32a3e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 22 deletions.
55 changes: 33 additions & 22 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: CD

on:
pull_request:
push:
branches:
- main
Expand All @@ -21,26 +22,30 @@ jobs:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine auditwheel validate-pyproject[all]
- name: Check and install package
python -m pip install --upgrade pip build validate-pyproject[all]
python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist
- name: Build wheels
run: |
validate-pyproject pyproject.toml
python -m build
python -m auditwheel repair dist/*.whl
python -m twine check --strict dist/*
python -m pip install dist/*.whl
docker run --rm -v `pwd`:/project -w /project quay.io/pypa/manylinux2014_x86_64 bash .github/workflows/docker/buildwheel.sh
- name: Check vcztools CLI
run: |
pip install numpy "zarr>=2.17,<3" click pyranges pyparsing
pip install vcztools --no-index --only-binary vcztools -f dist/wheelhouse
vcztools --help
# Make sure we don't have ``vcztools`` in the CWD
cd tests
python -m vcztools --help
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
name: linux-wheels
path: dist/wheelhouse

publish-to-pypi:
if: github.repository_owner == 'sgkit-dev' && github.event_name == 'release'
Expand All @@ -55,11 +60,14 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
- name: Download all
uses: actions/[email protected]
- name: Move to dist
run: |
mkdir dist
cp */*.{whl,gz} dist/.
ls dist
- uses: pypa/gh-action-pypi-publish@release/v1


publish-to-testpypi:
Expand All @@ -76,11 +84,14 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
repository-url: https://test.pypi.org/legacy/
- name: Download all
uses: actions/[email protected]
- name: Move to dist
run: |
mkdir dist
cp */*.{whl,gz} dist/.
ls dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
repository-url: https://test.pypi.org/legacy/
30 changes: 30 additions & 0 deletions .github/workflows/docker/buildwheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
DOCKER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$DOCKER_DIR/shared.env"

set -e -x

ARCH=`uname -p`
echo "arch=$ARCH"

# We're running as root in the docker container so git commands issued by
# setuptools_scm will fail without this:
git config --global --add safe.directory /project
# Fetch the full history as we'll be missing tags otherwise.
git fetch --unshallow
for V in "${PYTHON_VERSIONS[@]}"; do
git reset --hard
git clean -fd
PYBIN=/opt/python/$V/bin
rm -rf build/ # Avoid lib build by one Python is used by another
$PYBIN/python -m venv env
source env/bin/activate
$PYBIN/python -m pip install --upgrade build
SETUPTOOLS_SCM_DEBUG=1 $PYBIN/python -m build
done

cd dist
for whl in *.whl; do
auditwheel -v repair "$whl"
rm "$whl"
done
6 changes: 6 additions & 0 deletions .github/workflows/docker/shared.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PYTHON_VERSIONS=(
cp39-cp39
cp310-cp310
cp311-cp311
cp312-cp312
)

0 comments on commit 8b32a3e

Please sign in to comment.