Skip to content

Commit 8b32a3e

Browse files
authored
Merge pull request #135 from benjeffery/build-wheels-docker
Build wheels in docker
2 parents 89924d7 + c2fe255 commit 8b32a3e

File tree

3 files changed

+69
-22
lines changed

3 files changed

+69
-22
lines changed

.github/workflows/cd.yml

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: CD
22

33
on:
4+
pull_request:
45
push:
56
branches:
67
- main
@@ -21,26 +22,30 @@ jobs:
2122
python-version: '3.11'
2223
- name: Install dependencies
2324
run: |
24-
python -m pip install --upgrade pip
25-
python -m pip install build twine auditwheel validate-pyproject[all]
26-
- name: Check and install package
25+
python -m pip install --upgrade pip build validate-pyproject[all]
26+
python -m build --sdist
27+
- name: Upload sdist
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: sdist
31+
path: dist
32+
- name: Build wheels
2733
run: |
2834
validate-pyproject pyproject.toml
29-
python -m build
30-
python -m auditwheel repair dist/*.whl
31-
python -m twine check --strict dist/*
32-
python -m pip install dist/*.whl
35+
docker run --rm -v `pwd`:/project -w /project quay.io/pypa/manylinux2014_x86_64 bash .github/workflows/docker/buildwheel.sh
3336
- name: Check vcztools CLI
3437
run: |
38+
pip install numpy "zarr>=2.17,<3" click pyranges pyparsing
39+
pip install vcztools --no-index --only-binary vcztools -f dist/wheelhouse
3540
vcztools --help
3641
# Make sure we don't have ``vcztools`` in the CWD
3742
cd tests
3843
python -m vcztools --help
3944
- name: Store the distribution packages
4045
uses: actions/upload-artifact@v4
4146
with:
42-
name: python-package-distributions
43-
path: dist/
47+
name: linux-wheels
48+
path: dist/wheelhouse
4449

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

5762
steps:
58-
- uses: actions/download-artifact@v4
59-
with:
60-
name: python-package-distributions
61-
path: dist/
62-
- uses: pypa/gh-action-pypi-publish@release/v1
63+
- name: Download all
64+
uses: actions/download-artifact@v4.1.8
65+
- name: Move to dist
66+
run: |
67+
mkdir dist
68+
cp */*.{whl,gz} dist/.
69+
ls dist
70+
- uses: pypa/gh-action-pypi-publish@release/v1
6371

6472

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

7886
steps:
79-
- uses: actions/download-artifact@v4
80-
with:
81-
name: python-package-distributions
82-
path: dist/
83-
- uses: pypa/gh-action-pypi-publish@release/v1
84-
with:
85-
verbose: true
86-
repository-url: https://test.pypi.org/legacy/
87+
- name: Download all
88+
uses: actions/download-artifact@v4.1.8
89+
- name: Move to dist
90+
run: |
91+
mkdir dist
92+
cp */*.{whl,gz} dist/.
93+
ls dist
94+
- uses: pypa/gh-action-pypi-publish@release/v1
95+
with:
96+
verbose: true
97+
repository-url: https://test.pypi.org/legacy/
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
DOCKER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
source "$DOCKER_DIR/shared.env"
4+
5+
set -e -x
6+
7+
ARCH=`uname -p`
8+
echo "arch=$ARCH"
9+
10+
# We're running as root in the docker container so git commands issued by
11+
# setuptools_scm will fail without this:
12+
git config --global --add safe.directory /project
13+
# Fetch the full history as we'll be missing tags otherwise.
14+
git fetch --unshallow
15+
for V in "${PYTHON_VERSIONS[@]}"; do
16+
git reset --hard
17+
git clean -fd
18+
PYBIN=/opt/python/$V/bin
19+
rm -rf build/ # Avoid lib build by one Python is used by another
20+
$PYBIN/python -m venv env
21+
source env/bin/activate
22+
$PYBIN/python -m pip install --upgrade build
23+
SETUPTOOLS_SCM_DEBUG=1 $PYBIN/python -m build
24+
done
25+
26+
cd dist
27+
for whl in *.whl; do
28+
auditwheel -v repair "$whl"
29+
rm "$whl"
30+
done

.github/workflows/docker/shared.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PYTHON_VERSIONS=(
2+
cp39-cp39
3+
cp310-cp310
4+
cp311-cp311
5+
cp312-cp312
6+
)

0 commit comments

Comments
 (0)