meson 15 #158
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 on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
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 | |
- 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)" | |
pip3 install numpy | |
# Test | |
- name: Install package and dependencies | |
if: runner.os != 'macos' | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade numpy | |
# Test | |
- name: Install package and dependencies | |
if: runner.os != 'macos' | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade numpy | |
# Build wheel for windows with CUDA enabled. Note that cibuildwheel | |
# does not need manylinux docker, thuns, CUDA can be installed in | |
# the github action's virtual machine using the Jimver's action | |
# in the previous action (see above). | |
- name: Build wheels in windows (X86_64) | |
if: matrix.os == 'windows-latest' | |
uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS_WINDOWS: "AMD64 x86" | |
CIBW_BUILD: "*-win_amd64" | |
CIBW_SKIP: "pp* cp36-* cp37-* cp38-*" | |
CIBW_BUILD_VERBOSITY: 1 | |
with: | |
output-dir: wheelhouse | |
# Build wheel for windows with CUDA enabled. Note that cibuildwheel | |
# does not need manylinux docker, thuns, CUDA can be installed in | |
# the github action's virtual machine using the Jimver's action | |
# in the previous action (see above). | |
- name: Build wheels in windows (ARM64) | |
if: matrix.os == 'windows-latest' | |
uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS_WINDOWS: "ARM64" | |
CIBW_BUILD: "*-win_arm64" | |
CIBW_SKIP: "pp* cp36-* cp37-* cp38-*" | |
CIBW_BUILD_VERBOSITY: 1 | |
with: | |
output-dir: wheelhouse | |
# Do not enable compiling with CUDA for macos since NIVDIA no | |
# longer supports CUDA in the macos. | |
- name: Build wheels in mac (X86_64) | |
if: matrix.os == 'macos-latest' | |
uses: pypa/[email protected] | |
env: | |
CIBW_ARCHS_MACOS: "x86_64" | |
CIBW_BUILD: "*-macosx_x86_64" | |
CIBW_SKIP: "pp* cp36-* cp37-* cp38-*" | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_BEFORE_BUILD: brew reinstall gcc | |
with: | |
output-dir: wheelhouse | |
# Do not enable compiling with CUDA for macos since NIVDIA no | |
# longer supports CUDA in the macos. | |
# - name: Build wheels in mac (arm64) | |
# if: matrix.os == 'macos-latest' | |
# uses: pypa/[email protected] | |
# env: | |
# CIBW_ARCHS_MACOS: "arm64" | |
# CIBW_BUILD: "*-macosx_arm64" | |
# CIBW_SKIP: "pp* cp36-* cp37-* cp38-*" | |
# CIBW_BUILD_VERBOSITY: 1 | |
# CIBW_BEFORE_BUILD: brew reinstall gcc | |
# with: | |
# output-dir: wheelhouse | |
# Enable compiling with CUDA, only for linux. Note that cuda must | |
# be installed "inside" the manylinux docker image, not in the main | |
# github virtual machine. Also, we should use manylinux2014, but | |
# not manylinux1. Because of this, we will not install CUDA with | |
# the Jimver's action (unlike we did so for the windows wheel in | |
# the above). The ``CUDA_DYNAMIC_LOADING=0`` disables dynamic | |
# loading of CUDA library. Base of this, when the wheels are | |
# created in manylinux platform, the cuda's libraries | |
# (libcudart.so, libcublas.so, libcusparse.so) will bundle to | |
# the wheel. This is increases the wheel size, bit since the | |
# anaconda cloud upload size is 1GB, the large wheel size will not | |
# be a problem. The advantage of bundling cuda libraries to the | |
# wheel is that the end-user does not have to install cuda toolkit. | |
- name: Build wheels in linux (X86_64) | |
if: matrix.os == 'ubuntu-latest' | |
uses: pypa/[email protected] | |
env: | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_ARCHS_LINUX: "x86_64" | |
CIBW_BUILD: "*-manylinux_x86_64" | |
CIBW_SKIP: "pp37-* cp36-* cp37-* cp38-*" | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_BEFORE_BUILD_LINUX: yum update; yum install gcc-gfortran openblas-devel.x86_64 lapack-devel.x86_64 -y | |
# CIBW_BEFORE_BUILD_LINUX: yum update; yum install gcc-gfortran openblas-devel.x86_64 lapack-devel.x86_64 -y; python -m pip install --upgrade pip; python -m pip install --upgrade numpy | |
with: | |
output-dir: wheelhouse | |
# This does not work, the compilation takes several hours, then fails, even without enabling cuda. | |
# - name: Build wheels in linux (AARCH64) | |
# if: matrix.os == 'ubuntu-latest' | |
# uses: pypa/[email protected] | |
# env: | |
# CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 | |
# CIBW_ARCHS_LINUX: "aarch64" | |
# CIBW_BUILD: "*-manylinux_aarch64" | |
# CIBW_SKIP: "pp37* cp36-* cp37-* cp38-*" | |
# CIBW_BUILD_VERBOSITY: 1 | |
# # CIBW_BEFORE_BUILD_LINUX: yum update; yum install gcc-gfortran openblas-devel.x86_64 lapack-devel.x86_64 -y; python -m pip install --upgrade pip; python -m pip install --upgrade numpy | |
# with: | |
# output-dir: wheelhouse | |
- 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 | |
- name: Test | |
run: | | |
python -m pip install numpy | |
python -m pip install -r tests/requirements.txt | |
mv special_functions special_functions_do_dot_import | |
pytest |