| 1 |
name: Build wheel and deploy on PyPI |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_dispatch: |
| 5 |
release: |
| 6 |
types: |
| 7 |
- published |
| 8 |
|
| 9 |
jobs: |
| 10 |
build_sdist: |
| 11 |
name: Build source distribution |
| 12 |
runs-on: ubuntu-latest |
| 13 |
steps: |
| 14 |
- uses: actions/checkout@v4 |
| 15 |
- uses: actions/setup-python@v5 |
| 16 |
with: |
| 17 |
python-version: "3.12" |
| 18 |
cache: "pip" |
| 19 |
- name: Install dependencies |
| 20 |
run: | |
| 21 |
python -m pip install --upgrade pip |
| 22 |
pip install build twine pillow |
| 23 |
- name: Build sdist |
| 24 |
run: python -m build --sdist |
| 25 |
- name: Check the package |
| 26 |
run: python -m twine check dist/* |
| 27 |
- uses: actions/upload-artifact@v4 |
| 28 |
with: |
| 29 |
name: cibw-sdist |
| 30 |
path: dist/*.tar.gz |
| 31 |
|
| 32 |
test_sdist: |
| 33 |
needs: [build_sdist] |
| 34 |
name: Test source distribution |
| 35 |
runs-on: ubuntu-latest |
| 36 |
steps: |
| 37 |
- uses: actions/checkout@v4 |
| 38 |
- uses: actions/setup-python@v5 |
| 39 |
with: |
| 40 |
python-version: "3.12" |
| 41 |
cache: "pip" |
| 42 |
- uses: actions/download-artifact@v4 |
| 43 |
with: |
| 44 |
name: cibw-sdist |
| 45 |
path: dist |
| 46 |
- name: Install from sdist |
| 47 |
run: pip install "$(ls dist/freesas-*.tar.gz)" |
| 48 |
- name: Run tests |
| 49 |
env: |
| 50 |
WITH_QT_TEST: "False" # skip GUI tests |
| 51 |
PYFAI_OPENCL: "False" # skip GPU tests |
| 52 |
PYFAI_LOW_MEM: "True" # skip all tests >100Mb |
| 53 |
WITH_GL_TEST: "False" # disable tests using OpenGL |
| 54 |
run: python -c "import freesas.test, sys; sys.exit(freesas.test.run_tests())" |
| 55 |
|
| 56 |
build_doc: |
| 57 |
name: Build documentation |
| 58 |
runs-on: ubuntu-latest |
| 59 |
steps: |
| 60 |
- uses: actions/checkout@v4 |
| 61 |
- uses: actions/setup-python@v5 |
| 62 |
with: |
| 63 |
python-version: "3.12" |
| 64 |
cache: "pip" |
| 65 |
- name: Install pandoc&graphviz |
| 66 |
run: sudo apt-get install pandoc graphviz |
| 67 |
- name: Install freesas |
| 68 |
run: pip install . |
| 69 |
- name: Install documentation dependencies |
| 70 |
run: pip install -r ci/requirements_rtd.txt |
| 71 |
- name: Build doc |
| 72 |
env: |
| 73 |
READTHEDOCS: "True" # To skip checking that freesas is installed locally |
| 74 |
run: | |
| 75 |
export FREESAS_VERSION="$(python -c 'import freesas; print(freesas.strictversion)')" |
| 76 |
sphinx-build doc/source/ "freesas-${FREESAS_VERSION}_documentation/" |
| 77 |
zip -r "freesas-${FREESAS_VERSION}_documentation.zip" "freesas-${FREESAS_VERSION}_documentation/" |
| 78 |
- uses: actions/upload-artifact@v4 |
| 79 |
with: |
| 80 |
name: documentation |
| 81 |
path: freesas-*_documentation.zip |
| 82 |
|
| 83 |
build_wheels: |
| 84 |
name: Build wheels on ${{ matrix.os }}-${{ matrix.cibw_archs }} |
| 85 |
runs-on: ${{ matrix.os }} |
| 86 |
strategy: |
| 87 |
# Ensure that a wheel builder finishes even if another fails |
| 88 |
fail-fast: false |
| 89 |
matrix: |
| 90 |
include: |
| 91 |
- os: ubuntu-20.04 |
| 92 |
cibw_archs: "auto64" |
| 93 |
# - os: ubuntu-20.04 |
| 94 |
# cibw_archs: "aarch64" |
| 95 |
# - os: ubuntu-20.04 |
| 96 |
# cibw_archs: "ppc64le" |
| 97 |
- os: windows-2022 |
| 98 |
cibw_archs: "auto64" |
| 99 |
- os: macos-12 |
| 100 |
cibw_archs: "x86_64" |
| 101 |
macos_target: "10.9" |
| 102 |
- os: macos-14 |
| 103 |
cibw_archs: "arm64" |
| 104 |
macos_target: "11.0" |
| 105 |
|
| 106 |
steps: |
| 107 |
- uses: actions/checkout@v4 |
| 108 |
- uses: docker/setup-qemu-action@v3 |
| 109 |
if: runner.os == 'Linux' |
| 110 |
with: |
| 111 |
platforms: all |
| 112 |
- uses: ilammy/msvc-dev-cmd@v1 |
| 113 |
# - name: Install Ubuntu dependencies |
| 114 |
# run: | |
| 115 |
# sudo apt-get update |
| 116 |
# sudo apt-get install -y libopenblas-dev libatlas-base-dev liblapack-dev gfortran libgmp-dev libmpfr-dev libhdf5-dev ccache |
| 117 |
- uses: pypa/[email protected] |
| 118 |
env: |
| 119 |
# Use silx wheelhouse: needed for ppc64le |
| 120 |
CIBW_ENVIRONMENT_LINUX: "PIP_FIND_LINKS=https://www.silx.org/pub/wheelhouse/ PIP_TRUSTED_HOST=www.silx.org" |
| 121 |
#CIBW_ENVIRONMENT_WINDOWS: "PYFAI_WITH_OPENMP=False" |
| 122 |
CIBW_BUILD_FRONTEND_WINDOWS: "build; args: -C setup-args=-Duse_openmp=disabled" |
| 123 |
#CIBW_BEFORE_BUILD_WINDOWS: '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"' |
| 124 |
CIBW_BUILD_VERBOSITY: 1 |
| 125 |
CIBW_BUILD: cp310-* cp311-* cp312-* cp313-* cp314-* |
| 126 |
# Do not build for pypy and muslinux |
| 127 |
CIBW_SKIP: pp* *-musllinux_* |
| 128 |
CIBW_ARCHS: ${{ matrix.cibw_archs }} |
| 129 |
|
| 130 |
MACOSX_DEPLOYMENT_TARGET: "${{ matrix.macos_target }}" |
| 131 |
|
| 132 |
# Install test dependencies |
| 133 |
CIBW_TEST_COMMAND: python -c "import freesas.test, sys; sys.exit(freesas.test.run_tests())" |
| 134 |
# Skip tests for emulated architectures |
| 135 |
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x} cp312-win_amd64" |
| 136 |
WITH_QT_TEST: "False" # skip GUI tests |
| 137 |
PYFAI_OPENCL: "False" # skip GPU tests |
| 138 |
PYFAI_LOW_MEM: "True" # skip all tests >100Mb |
| 139 |
WITH_GL_TEST: "False" # disable tests using OpenGL |
| 140 |
- uses: actions/upload-artifact@v4 |
| 141 |
with: |
| 142 |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 143 |
path: ./wheelhouse/*.whl |
| 144 |
|
| 145 |
pypi-publish: |
| 146 |
needs: [build_doc, build_sdist, build_wheels, test_sdist] |
| 147 |
name: Upload release to PyPI |
| 148 |
runs-on: ubuntu-latest |
| 149 |
environment: |
| 150 |
name: pypi |
| 151 |
permissions: |
| 152 |
id-token: write |
| 153 |
if: github.event_name == 'release' && github.event.action == 'published' |
| 154 |
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) |
| 155 |
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 156 |
steps: |
| 157 |
- uses: actions/download-artifact@v4 |
| 158 |
with: |
| 159 |
pattern: cibw-* |
| 160 |
path: dist |
| 161 |
merge-multiple: true |
| 162 |
- uses: pypa/gh-action-pypi-publish@release/v1 |