Skip to content

Packaging QuadDType

Packaging QuadDType #2

Workflow file for this run

name: Build Wheels
on:
push:
branches:
- uni-workflow
tags:
- "v*"
pull_request:
jobs:
build_wheels_linux:
name: Build wheels on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ">=3.10.0"
- name: Install cibuildwheel
run: pip install cibuildwheel==2.20.0
- name: Build wheels
env:
CIBW_BUILD: "cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_BUILD_VERBOSITY: "3"
CIBW_BEFORE_ALL: |
yum install -y wget
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p /root/miniconda
export PATH="/root/miniconda/bin:$PATH"
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda info -a
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -n build_env python=3.10
source activate build_env
conda install -y sleef
CIBW_ENVIRONMENT: >
LD_LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LD_LIBRARY_PATH"
LIBRARY_PATH="/root/miniconda/envs/build_env/lib:$LIBRARY_PATH"
CFLAGS="-I/root/miniconda/envs/build_env/include $CFLAGS"
CXXFLAGS="-I/root/miniconda/envs/build_env/include $CXXFLAGS"
LDFLAGS="-L/root/miniconda/envs/build_env/lib $LDFLAGS"
SLEEF_PATH="/root/miniconda/envs/build_env"
CIBW_REPAIR_WHEEL_COMMAND: >
auditwheel repair -w {dest_dir} --plat manylinux_2_28_x86_64 {wheel}
CIBW_TEST_COMMAND: |
python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))"
python -c "import platform; print('Python version:', platform.python_version())"
python -c "import sys; print('sys.platform:', sys.platform)"
python -c "import quaddtype; print('quaddtype imported successfully')"
pip install {package}[test]
pytest {project}/tests
CIBW_TEST_EXTRAS: "test"
run: |
python -m cibuildwheel --output-dir wheelhouse
working-directory: ./quaddtype
- uses: actions/upload-artifact@v3
with:
path: ./quaddtype/wheelhouse/*.whl
name: wheels-linux
build_wheels_macos:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, macos-14]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ">=3.10.0"
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.10"
channels: conda-forge
- name: Install SLEEF
shell: bash -l {0}
run: |
conda install -y -c conda-forge sleef
echo $CONDA_PREFIX
echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV
- name: Install cibuildwheel
run: pip install cibuildwheel==2.20.0
- name: Build wheels
env:
CIBW_BUILD_VERBOSITY: "1"
CIBW_ARCHS_MACOS: ${{ matrix.os == 'macos-13' && 'x86_64' || 'arm64' }}
CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*"
CIBW_ENVIRONMENT: >
SLEEF_PATH="${{ env.SLEEF_PATH }}"
DYLD_LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$DYLD_LIBRARY_PATH"
LIBRARY_PATH="${{ env.SLEEF_PATH }}/lib:$LIBRARY_PATH"
CFLAGS="-I${{ env.SLEEF_PATH }}/include $CFLAGS"
CXXFLAGS="-I${{ env.SLEEF_PATH }}/include $CXXFLAGS"
LDFLAGS="-L${{ env.SLEEF_PATH }}/lib $LDFLAGS"
MACOSX_DEPLOYMENT_TARGET="10.13"
CIBW_REPAIR_WHEEL_COMMAND: "delocate-wheel -w {dest_dir} -v {wheel}"
CIBW_TEST_COMMAND: |
python -c "import os; print('SLEEF_PATH:', os.environ.get('SLEEF_PATH', 'Not set'))"
python -c "import platform; print('Python version:', platform.python_version())"
python -c "import sys; print('sys.platform:', sys.platform)"
python -c "import quaddtype; print('quaddtype imported successfully')"
pip install {package}[test]
pytest {project}/tests
CIBW_TEST_EXTRAS: "test"
run: |
echo "SLEEF_PATH: $SLEEF_PATH"
ls $SLEEF_PATH/include/sleef*
echo "PATH: $PATH"
which python
python --version
which pip
pip --version
cd quaddtype
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v3
with:
path: ./quaddtype/wheelhouse/*.whl
name: wheels-${{ matrix.os }}
build_wheels_windows:
name: Build wheels on Windows
runs-on: windows-latest
strategy:
matrix:
architecture: [x64]
steps:
- uses: actions/checkout@v3
- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.architecture }}
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
architecture: ${{ matrix.architecture }}
- name: Install Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.10"
architecture: ${{ matrix.architecture }}
- name: Install SLEEF and other dependencies
shell: bash -l {0}
run: |
conda config --add channels conda-forge
conda config --set channel_priority strict
conda install -y sleef numpy
conda list
if [ ! -f "$CONDA_PREFIX/Library/include/sleef.h" ]; then
echo "sleef.h not found. Installation may have failed."
exit 1
fi
ls -l "$CONDA_PREFIX/Library/include/sleef.h"
ls -l "$CONDA_PREFIX/Library/lib/sleef"*
- name: Set environment variables
shell: pwsh
run: |
echo "CONDA_PREFIX=$env:CONDA_PREFIX" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$numpy_path = python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))"
echo "NUMPY_INCLUDE_DIR=$numpy_path" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install build dependencies
shell: bash -l {0}
run: |
pip install -U pip
pip install cibuildwheel==2.20.0 ninja meson meson-python numpy delvewheel pytest
- name: Build wheels
env:
CONDA_PREFIX: ${{ env.CONDA_PREFIX }}
CIBW_SKIP: "pp* cp36-* cp37-* cp38-* cp39-* cp313-*"
CIBW_ARCHS_WINDOWS: ${{ matrix.architecture == 'x86' && 'x86' || 'AMD64' }}
CIBW_BUILD_VERBOSITY: "1"
SLEEF_INCLUDE_DIR: ${{ env.CONDA_PREFIX }}\Library\include
SLEEF_LIBRARY: ${{ env.CONDA_PREFIX }}\Library\lib
DISTUTILS_USE_SDK: "1"
MSSdk: "1"
NUMPY_INCLUDE_DIR: ${{ env.NUMPY_INCLUDE_DIR }}
CIBW_ENVIRONMENT: >-
NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}"
SLEEF_INCLUDE_DIR="${{ env.CONDA_PREFIX }}/Library/include"
SLEEF_LIBRARY="${{ env.CONDA_PREFIX }}/Library/lib"
CIBW_BEFORE_BUILD: pip install meson meson-python ninja numpy
CIBW_REPAIR_WHEEL_COMMAND: "delvewheel repair -w {dest_dir} {wheel}"
CIBW_TEST_COMMAND: |
python -c "import platform; print('Python version:', platform.python_version())"
python -c "import sys; print('sys.platform:', sys.platform)"
python -c "import quaddtype; print('quaddtype imported successfully')"
pip install {package}[test]
pytest {project}\tests -v || (echo "Tests failed" && exit 1)
CIBW_TEST_EXTRAS: "test"
CIBW_TEST_FAIL_FAST: 1
shell: pwsh
run: |
python -m cibuildwheel --output-dir wheelhouse
if (-not (Test-Path wheelhouse/*.whl)) { throw "Wheel was not created" }
working-directory: ./quaddtype
- uses: actions/upload-artifact@v3
with:
path: ./quaddtype/wheelhouse/*.whl
name: wheels-windows-${{ matrix.architecture }}
publish_to_testpypi:
name: Publish to TestPyPI
needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
with:
path: dist
- name: Publish to TestPyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/*
create_release:
name: Create Release
needs: [build_wheels_linux, build_wheels_macos, build_wheels_windows]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./artifacts/**/*.whl
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}