Build and Upload Wheels #41
Workflow file for this run
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: Build and Upload Wheels | |
on: | |
push: | |
tags: | |
- 'v*' | |
permissions: | |
id-token: write # Grant the workflow permissions to use the id-token | |
jobs: | |
build-linux-wheels: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.10', '3.11', '3.12'] | |
architecture: [x86_64, i686, aarch64] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Install QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up Docker image | |
run: | | |
docker pull quay.io/pypa/manylinux2014_${{ matrix.architecture }} | |
- name: List available Python versions | |
run: | | |
docker run --rm quay.io/pypa/manylinux2014_${{ matrix.architecture }} /bin/bash -c "ls -al /opt/_internal" | |
- name: Build wheels | |
run: | | |
docker run --rm -v $GITHUB_WORKSPACE:/project quay.io/pypa/manylinux2014_${{ matrix.architecture }} /bin/bash -c " | |
echo 'Starting the Docker container' >> /project/build.log | |
yum install -y fftw-devel && \ | |
echo 'FFTW installed' >> /project/build.log && \ | |
mkdir -p /project/dist/${{ matrix.architecture }} && \ | |
echo 'Created dist directory' >> /project/build.log && \ | |
for PYBIN in /opt/_internal/cpython-${{ matrix.python-version }}*/bin; do | |
echo 'Checking directory' \$PYBIN >> /project/build.log | |
if [ -d \$PYBIN ]; then | |
echo 'Using Python binary from' \$PYBIN >> /project/build.log | |
\$PYBIN/python -m ensurepip >> /project/build.log 2>&1 && \ | |
echo 'Ensured pip' >> /project/build.log && \ | |
\$PYBIN/pip install -U pip setuptools wheel auditwheel pybind11 >> /project/build.log 2>&1 && \ | |
echo 'Installed dependencies' >> /project/build.log && \ | |
cd /project && \ | |
echo 'Building wheel with Python binary from' \$PYBIN >> /project/build.log && \ | |
\$PYBIN/python setup.py bdist_wheel >> /project/build.log 2>&1 && \ | |
echo 'Built wheel' >> /project/build.log && \ | |
\$PYBIN/auditwheel repair dist/*.whl --plat manylinux2014_${{ matrix.architecture }} -w /project/dist/${{ matrix.architecture }} >> /project/build.log 2>&1 && \ | |
echo 'Repaired wheel' >> /project/build.log && \ | |
rm -f dist/*linux_x86_64.whl && \ | |
echo 'Removed non-compliant wheels' >> /project/build.log | |
else | |
echo 'Directory' \$PYBIN 'does not exist' >> /project/build.log | |
fi | |
done | |
echo 'Contents of /project/dist/${{ matrix.architecture }}:' >> /project/build.log | |
ls -al /project/dist/${{ matrix.architecture }} >> /project/build.log | |
" | |
- name: Output build logs | |
run: | | |
if [ -f $GITHUB_WORKSPACE/build.log ]; then cat $GITHUB_WORKSPACE/build.log; else echo "Build log not found"; fi | |
- name: Verify wheels | |
run: | | |
ls -al $GITHUB_WORKSPACE/dist/${{ matrix.architecture }}/ | |
- name: Upload to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages_dir: dist/${{ matrix.architecture }} | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
build-macos-wheels: | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
python-version: ['3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
run: | | |
brew install pyenv | |
pyenv install ${{ matrix.python-version }} | |
pyenv global ${{ matrix.python-version }} | |
echo "Python version set to $(python --version)" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel pybind11 | |
brew install fftw | |
- name: Build x86_64 wheel | |
env: | |
ARCHFLAGS: "-arch x86_64" | |
MACOSX_DEPLOYMENT_TARGET: "11.0" | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/dist | |
python setup.py bdist_wheel | |
- name: Repair x86_64 wheel | |
run: | | |
pip install delocate | |
delocate-wheel dist/*-macosx_11_0_x86_64.whl | |
- name: Build arm64 wheel | |
env: | |
ARCHFLAGS: "-arch arm64" | |
MACOSX_DEPLOYMENT_TARGET: "11.0" | |
run: | | |
python setup.py bdist_wheel | |
- name: Repair arm64 wheel | |
run: | | |
delocate-wheel dist/*-macosx_11_0_arm64.whl | |
- name: Verify repaired wheels | |
run: | | |
ls -al $GITHUB_WORKSPACE/dist/ | |
- name: Upload to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages_dir: dist | |
password: ${{ secrets.PYPI_API_TOKEN }} |