File: build-python-wheels.yml

package info (click to toggle)
sail 0.9.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,568 kB
  • sloc: ansic: 44,502; cpp: 9,648; python: 4,139; sh: 140; makefile: 5
file content (221 lines) | stat: -rw-r--r-- 6,699 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Build Python Wheels

on:
  push:
    branches: [ master, main ]
    tags:
      - 'v*'
  pull_request:
    branches: [ master, main ]
  workflow_dispatch:

jobs:
  build_wheels:
    name: Build wheels on ${{ matrix.os }} - Python ${{ matrix.python-version }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest]
        python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']

    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install build dependencies (Ubuntu)
      if: runner.os == 'Linux'
      run: |
        sudo apt-get update
        sudo apt-get install -y cmake libavif-dev libgif-dev libheif-dev libjbig-dev libjpeg-dev libjxl-dev \
                                libnanosvg-dev libopenexr-dev libopenjp2-7-dev libpng-dev libtiff-dev       \
                                libwebp-dev zlib1g-dev

    - name: Install build dependencies (macOS)
      if: runner.os == 'macOS'
      run: |
        brew install python
        brew install giflib jbigkit jpeg-turbo jpeg-xl libavif libheif libpng libtiff openexr openjpeg webp

    - name: Set up vcpkg cache
      uses: actions/cache@v4
      with:
        path: vcpkg
        key: vcpkg-${{ runner.os }}

    - name: Set up vcpkg (Windows)
      shell: bash
      if: runner.os == 'Windows'
      run: |
        if [ ! -f "vcpkg/vcpkg.exe" ]; then
          rm -rf vcpkg
          git clone https://github.com/microsoft/vcpkg.git
          vcpkg/bootstrap-vcpkg.bat
        fi
        git -C vcpkg pull
        vcpkg/vcpkg install giflib jbigkit libavif libheif libjpeg-turbo libjxl libpng libwebp nanosvg openexr openjpeg tiff zlib \
                            --triplet x64-windows --clean-buildtrees-after-build

    - name: Install Python build tools
      run: |
        python -m pip install --upgrade pip
        pip install build twine wheel setuptools pybind11 numpy

    - name: Install auditwheel (Linux only)
      if: runner.os == 'Linux'
      run: pip install auditwheel patchelf

    - name: Install delocate (macOS only)
      if: runner.os == 'macOS'
      run: pip install delocate

    - name: Build wheel (Linux)
      if: runner.os == 'Linux'
      working-directory: src/bindings/sail-python
      run: |
        python -m build --wheel
        mkdir -p wheelhouse
        for wheel in dist/*.whl; do
          auditwheel repair "$wheel" -w wheelhouse/
        done

    - name: Build wheel (macOS)
      if: runner.os == 'macOS'
      working-directory: src/bindings/sail-python
      env:
        CMAKE_ARGS: -DCMAKE_OSX_ARCHITECTURES=arm64
      run: |
        python -m build --wheel
        mkdir -p wheelhouse
        for wheel in dist/*.whl; do
          python -m delocate.libsana delocate-wheel -w wheelhouse/ "$wheel"
        done

    - name: Build wheel (Windows)
      if: runner.os == 'Windows'
      shell: bash
      working-directory: src/bindings/sail-python
      env:
        CMAKE_ARGS: -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_C_FLAGS=-MP -DCMAKE_CXX_FLAGS=-MP
      run: |
        python -m build --wheel
        mkdir -p wheelhouse
        mv dist/*.whl wheelhouse/

    - name: Check wheels
      shell: bash
      working-directory: src/bindings/sail-python
      run: |
        twine check --strict wheelhouse/*.whl

    - name: Test wheel installation
      shell: bash
      working-directory: src/bindings/sail-python
      run: |
        pip install wheelhouse/*.whl
        mv sailpy sailpy.backup
        python -c "import sailpy; print('sailpy version:', sailpy.__version__)"

    - name: Install test dependencies
      run: |
        pip install pytest

    - name: Run tests
      working-directory: src/bindings/sail-python
      run: |
        pytest tests/

        python -m sailpy.examples.01_quickstart
        python -m sailpy.examples.02_memory_io
        python -m sailpy.examples.03_features_and_options
        python -m sailpy.examples.04_numpy_integration
        python -m sailpy.examples.05_multiframe
        python -m sailpy.examples.06_probe
        python -m sailpy.examples.07_codec_info
        python -m sailpy.examples.08_logging
        python -m sailpy.examples.09_image_transformations
        python -m sailpy.examples.10_enum_usage
        python -m sailpy.examples.11_advanced_saving

    - name: Upload wheels as artifacts
      uses: actions/upload-artifact@v4
      with:
        name: wheels-${{ matrix.os }}-py${{ matrix.python-version }}
        path: src/bindings/sail-python/wheelhouse/*.whl
        retention-days: 30

  build_sdist:
    name: Build source distribution
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: '3.11'

    - name: Install build dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y cmake libavif-dev libgif-dev libheif-dev libjbig-dev libjpeg-dev libjxl-dev \
                                libnanosvg-dev libopenexr-dev libopenjp2-7-dev libpng-dev libtiff-dev       \
                                libwebp-dev zlib1g-dev

    - name: Install Python build tools
      run: |
        python -m pip install --upgrade pip
        pip install build setuptools pybind11 numpy

    - name: Build sdist
      working-directory: src/bindings/sail-python
      run: python -m build --sdist

    - name: Upload sdist as artifact
      uses: actions/upload-artifact@v4
      with:
        name: sdist
        path: src/bindings/sail-python/dist/*.tar.gz
        retention-days: 30

  upload_pypi:
    name: Upload wheels to PyPI
    needs: [build_wheels, build_sdist]
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
    environment:
      name: pypi
      url: https://pypi.org/p/sailpy
    permissions:
      id-token: write

    steps:
    - name: Download all wheels
      uses: actions/download-artifact@v4
      with:
        pattern: wheels-*
        path: dist
        merge-multiple: true

    - name: Download sdist
      uses: actions/download-artifact@v4
      with:
        name: sdist
        path: dist

    - name: List all distributions
      run: ls -lh dist/

    - name: Publish to PyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        skip-existing: true