pypy final #172
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: deploy-pypi | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: | |
- published | |
jobs: | |
build_wheels: | |
name: Build wheels, ${{ matrix.os }}, ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
python-version: ['cp39', 'cp310', 'cp311', 'cp312', 'pp38', 'pp39', 'pp310'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
# Without this, installing cuda give error: no much space left on device | |
- name: Clear Cache | |
if: matrix.os != 'windows-latest' | |
run: rm -rf /opt/hostedtoolcache | |
# Build wheel for windows X86_64 | |
- name: Build wheels in windows (X86_64) Python ${{ matrix.python-version }} | |
if: matrix.os == 'windows-latest' | |
uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS_WINDOWS: "AMD64 x86" | |
CIBW_BUILD: "${{ matrix.python-version }}-win_amd64" | |
CIBW_SKIP: "pp37-* cp36-* cp37-* cp38-*" | |
CIBW_BUILD_VERBOSITY: 3 | |
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel" | |
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" | |
with: | |
output-dir: wheelhouse | |
# Build wheel for windows ARM64 (DO NOT USE) | |
# Note: DO NOT build ARM64 for windows. The reason is that this github runner is an X86_64 | |
# machine. To build ARM64 wheels, cibuildwheels uses "cross compiling". This is supported | |
# possible when the build tool is "setuptools". But currently, it is not supported using meson.build. | |
# Since, this package uses meson.build, as such, cross compiling for ARM64 is not possible. | |
# - name: Build wheels in windows (ARM64) Python ${{ matrix.python-version }} | |
# if: matrix.os == 'windows-latest' | |
# uses: pypa/[email protected] | |
# env: | |
# CIBW_ARCHS_WINDOWS: "ARM64" | |
# CIBW_BUILD: "${{ matrix.python-version }}-win_arm64" | |
# CIBW_SKIP: "pp37-* cp36-* cp37-* cp38-*" | |
# CIBW_BUILD_VERBOSITY: 3 | |
# CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel" | |
# CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" | |
# with: | |
# output-dir: wheelhouse | |
# Build wheel for macos X86_64. | |
# Note that wheels for macos ARM64 will be built on cirrus ci (see /tools/ci) | |
- name: Build wheels in mac (X86_64) Python ${{ matrix.python-version }} | |
if: matrix.os == 'macos-latest' | |
uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS_MACOS: "x86_64" | |
CIBW_BUILD: "${{ matrix.python-version }}-macosx_x86_64" | |
CIBW_SKIP: "pp37-* cp36-* cp37-* cp38-*" | |
CIBW_BUILD_VERBOSITY: 3 | |
CIBW_BEFORE_BUILD: brew reinstall gcc | |
with: | |
output-dir: wheelhouse | |
# Build wheel for linux X86_64. | |
# Note that wheels for linux AARCH64 will be built on cirrus ci (see /tools/ci) | |
- name: Build wheels in linux (X86_64) Python ${{ matrix.python-version }} | |
if: matrix.os == 'ubuntu-latest' | |
uses: pypa/[email protected] | |
env: | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_ARCHS_LINUX: "x86_64" | |
CIBW_BUILD: "${{ matrix.python-version }}-manylinux_x86_64" | |
CIBW_SKIP: "pp37-* cp36-* cp37-* cp38-*" | |
CIBW_BUILD_VERBOSITY: 3 | |
# CIBW_BEFORE_BUILD_LINUX: yum update; yum install gcc-gfortran openblas-devel.x86_64 lapack-devel.x86_64 -y | |
with: | |
output-dir: wheelhouse | |
# Upload all wheels to an artifact | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ./wheelhouse/*.whl | |
retention-days: 1 | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Build sdist | |
run: | | |
python -m pip install build | |
python -m build . --sdist | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
path: dist/*.tar.gz | |
retention-days: 1 | |
upload_pypi: | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
name: Publish to PyPI | |
# upload to PyPI on every tag starting with 'v' | |
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') | |
# alternatively, to publish when a GitHub Release is created, use the following rule: | |
# if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: artifact | |
path: dist | |
- name: Upload to PyPi | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
verbose: true | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
test_pypi: | |
needs: [upload_pypi] | |
name: Test on ${{ matrix.os }} and Python ${{ matrix.python-version }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
python-version: ['3.9', '3.10', '3.11', '3.12'] | |
include: | |
- os: ubuntu-latest | |
python-version: 'pypy-3.8' | |
- os: ubuntu-latest | |
python-version: 'pypy-3.9' | |
- os: ubuntu-latest | |
python-version: 'pypy-3.10' | |
steps: | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# MacOS needs openblas to run the tests on pypy | |
- name: Install OpenMP and numpy for mac | |
if: runner.os == 'macos' | |
run: | | |
# This is needed to import numpy in pypy3 (but not needed for pypy2 and CPython) | |
brew install openblas | |
OPENBLAS="$(brew --prefix openblas)" | |
- name: Install packages | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install pytest-cov | |
python -m pip install --prefer-binary --upgrade special_functions | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Despite the package is built on both cpython and pypy, here we | |
# only test it on cpython, not on pypy, since tests require numpy and scipy | |
# (although, this package itself does not have numpy and scipy dependency, | |
# but the test scripts do depend on numpy and scipy). | |
# Often in pypy these packages do not have wheels, then have to be | |
# built from source. As such, it takes forever to build these in pypy! | |
# Thus, it is just simpler to not test this package with pypy. | |
- name: Test | |
if: (!contains(matrix.python-version, 'pypy')) | |
run: | | |
python -m pip install numpy | |
python -m pip install -r tests/requirements.txt | |
mv special_functions special_functions_do_not_import | |
pytest |