Packaging QuadDType #4
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 Wheels | |
on: | |
push: | |
branches: | |
- quaddtype-packaging | |
tags: | |
- 'v*' | |
pull_request: | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-13, macos-14, windows-latest] | |
include: | |
- os: ubuntu-latest | |
cibw_archs: 'x86_64' | |
- os: macos-13 | |
cibw_archs: 'x86_64' | |
- os: macos-14 | |
cibw_archs: 'arm64' | |
- os: windows-latest | |
cibw_archs: 'AMD64' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Setup Miniconda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
auto-update-conda: true | |
python-version: '3.10' | |
channels: conda-forge | |
- 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/include/sleef.h" ] && [ ! -f "$CONDA_PREFIX/Library/include/sleef.h" ]; then | |
echo "sleef.h not found. Installation may have failed." | |
exit 1 | |
fi | |
- name: Set environment variables | |
shell: bash -l {0} | |
run: | | |
if [ "${{ runner.os }}" == "Windows" ]; then | |
echo "SLEEF_PATH=$CONDA_PREFIX/Library" >> $GITHUB_ENV | |
echo "NUMPY_INCLUDE_DIR=$(python -c "import numpy; import os; print(os.path.abspath(numpy.get_include()).replace(os.sep, '/'))")" >> $GITHUB_ENV | |
else | |
echo "SLEEF_PATH=$CONDA_PREFIX" >> $GITHUB_ENV | |
fi | |
- name: Install cibuildwheel | |
run: pip install cibuildwheel==2.20.0 | |
- name: Build wheels | |
env: | |
CIBW_BUILD: 'cp310-* cp311-* cp312-*' | |
CIBW_SKIP: 'pp* *-win32 *-manylinux_i686' | |
CIBW_ARCHS: ${{ matrix.cibw_archs }} | |
CIBW_BUILD_VERBOSITY: '1' | |
CIBW_ENVIRONMENT: >- | |
SLEEF_PATH="${{ env.SLEEF_PATH }}" | |
NUMPY_INCLUDE_DIR="${{ env.NUMPY_INCLUDE_DIR }}" | |
PATH="${{ env.SLEEF_PATH }}/bin:$PATH" | |
${{ runner.os == 'Windows' && 'DISTUTILS_USE_SDK=1 MSSdk=1' || '' }} | |
CIBW_BEFORE_BUILD: >- | |
pip install -U pip && | |
pip install meson meson-python ninja numpy | |
CIBW_REPAIR_WHEEL_COMMAND: >- | |
${{ runner.os == 'Windows' && 'delvewheel repair -w {dest_dir} {wheel}' || | |
runner.os == 'macOS' && 'delocate-wheel -w {dest_dir} -v {wheel}' || | |
'auditwheel repair -w {dest_dir} {wheel}' }} | |
CIBW_TEST_COMMAND: | | |
python -c "import os, platform, sys, quaddtype; print(f'Python {platform.python_version()} on {sys.platform}')" | |
pip install {package}[test] | |
pytest {project}/tests -v | |
CIBW_TEST_EXTRAS: 'test' | |
CIBW_TEST_FAIL_FAST: 1 | |
run: python -m cibuildwheel --output-dir wheelhouse | |
working-directory: ./quaddtype | |
- uses: actions/upload-artifact@v3 | |
with: | |
path: ./quaddtype/wheelhouse/*.whl | |
name: wheels-${{ matrix.os }} | |
publish_to_testpypi: | |
name: Publish to TestPyPI | |
needs: [build_wheels] | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
path: dist | |
- uses: pypa/gh-action-pypi-publish@v1.9.0 | |
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] | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v2 | |
with: | |
path: artifacts | |
- 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 | |
- uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: ./artifacts/**/*.whl | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} |