|
1 | | -name: Python package |
2 | | -on: [push] |
| 1 | +name: Python wheels |
| 2 | +on: |
| 3 | + # Trigger the workflow on push or pull request, |
| 4 | + # but only for the main branch |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
3 | 11 | jobs: |
4 | | - build: |
5 | | - runs-on: ubuntu-latest |
| 12 | + build_wheels: |
| 13 | + name: Build wheels on ${{ matrix.os }} |
| 14 | + runs-on: ${{ matrix.os }} |
6 | 15 | strategy: |
7 | 16 | matrix: |
8 | | - python-version: [3.7, 3.8] |
| 17 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout repo |
| 21 | + uses: actions/checkout@v2 |
| 22 | + with: |
| 23 | + submodules: 'recursive' |
| 24 | + |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v2 |
| 27 | + with: |
| 28 | + python-version: '3.7' |
| 29 | + |
| 30 | + - name: Install Ninja |
| 31 | + uses: seanmiddleditch/gha-setup-ninja@master |
| 32 | + |
| 33 | + - name: Install MSVC x86 |
| 34 | + uses: ilammy/msvc-dev-cmd@v1 |
| 35 | + with: |
| 36 | + arch: x86 |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: | |
| 40 | + python -m pip install --upgrade pip |
| 41 | + pip install pytest |
| 42 | + pip install -r requirements.txt |
| 43 | +
|
| 44 | + - name: Build wheels (Windows x86) |
| 45 | + if: runner.os == 'Windows' |
| 46 | + run: | |
| 47 | + python -m pip install cibuildwheel |
| 48 | + python -m cibuildwheel --output-dir wheelhouse |
| 49 | + env: |
| 50 | + CIBW_BUILD: 'cp37-win32 cp38-win32 cp39-win32' |
| 51 | + CIBW_BEFORE_BUILD: pip install -r requirements.txt |
| 52 | + CIBW_BEFORE_TEST: pip install pytest numpy |
| 53 | + CIBW_TEST_COMMAND: pytest {project} |
| 54 | + CIBW_BUILD_VERBOSITY: 1 |
| 55 | + |
| 56 | + - name: Install MSVC amd64 |
| 57 | + uses: ilammy/msvc-dev-cmd@v1 |
| 58 | + with: |
| 59 | + arch: amd64 |
| 60 | + |
| 61 | + - name: Build wheels (Windows / amd64) |
| 62 | + if: runner.os == 'Windows' |
| 63 | + run: | |
| 64 | + python -m pip install cibuildwheel |
| 65 | + python -m cibuildwheel --output-dir wheelhouse |
| 66 | + env: |
| 67 | + CIBW_BUILD: 'cp37-win_amd64 cp38-win_amd64 cp39-win_amd64' |
| 68 | + CIBW_BEFORE_BUILD: pip install -r requirements.txt |
| 69 | + CIBW_BEFORE_TEST: pip install pytest numpy |
| 70 | + CIBW_TEST_COMMAND: pytest {project} |
| 71 | + CIBW_BUILD_VERBOSITY: 1 |
| 72 | + |
| 73 | + - name: Build wheels (Linux / macOS) |
| 74 | + if: runner.os != 'Windows' |
| 75 | + run: | |
| 76 | + python -m pip install cibuildwheel |
| 77 | + python -m cibuildwheel --output-dir wheelhouse |
| 78 | + env: |
| 79 | + CIBW_BUILD: 'cp37-* cp38-* cp39-*' |
| 80 | + CIBW_BEFORE_BUILD: pip install -r requirements.txt |
| 81 | + CIBW_BEFORE_TEST: | |
| 82 | + ls {project} |
| 83 | + pip install pytest |
| 84 | + pip install -r requirements.txt |
| 85 | + CIBW_TEST_COMMAND: pytest {project} |
| 86 | + CIBW_BUILD_VERBOSITY: 1 |
| 87 | + |
| 88 | + - name: Upload wheels |
| 89 | + uses: actions/upload-artifact@v2 |
| 90 | + with: |
| 91 | + path: ./wheelhouse/*.whl |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + build_sdist: |
| 97 | + name: Build SDist |
| 98 | + runs-on: ubuntu-latest |
9 | 99 | steps: |
10 | | - - uses: actions/checkout@v2 |
11 | | - with: |
12 | | - submodules: 'recursive' |
13 | | - - name: Set up Python ${{ matrix.python-version }} |
14 | | - uses: actions/setup-python@v2 |
15 | | - with: |
16 | | - python-version: ${{ matrix.python-version }} |
17 | | - - name: Install dependencies |
18 | | - run: | |
19 | | - python -m pip install --upgrade pip |
20 | | - pip install flake8 pytest |
21 | | - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
22 | | - - name: Build |
23 | | - run: | |
24 | | - python setup.py build_ext --inplace |
25 | | -
|
26 | | - - name: Lint with flake8 |
27 | | - run: | |
28 | | - # stop the build if there are Python syntax errors or undefined names |
29 | | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
30 | | - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
31 | | - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
32 | | - - name: Test with pytest |
33 | | - run: | |
34 | | - PYTHONPATH=. pytest |
| 100 | + - uses: actions/checkout@v2 |
| 101 | + with: |
| 102 | + submodules: 'recursive' |
| 103 | + |
| 104 | + - uses: actions/setup-python@v2 |
| 105 | + name: Setup Python ${{ matrix.python-version }} |
| 106 | + with: |
| 107 | + python-version: ${{ matrix.python-version }} |
| 108 | + |
| 109 | + - name: Install dependencies |
| 110 | + run: | |
| 111 | + python -m pip install --upgrade pip |
| 112 | + pip install pytest |
| 113 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 114 | +
|
| 115 | + - name: Build SDist |
| 116 | + run: | |
| 117 | + python setup.py sdist |
| 118 | +
|
| 119 | + - uses: actions/upload-artifact@v2 |
| 120 | + with: |
| 121 | + path: dist/*.tar.gz |
| 122 | + |
| 123 | + - name: Build extension from SDist package |
| 124 | + run: | |
| 125 | + cd ./dist |
| 126 | + tar -xzf blosc2-*.tar.gz |
| 127 | + cd ./blosc2-*/ |
| 128 | + python setup.py build_ext --inplace |
| 129 | +
|
| 130 | + - name: Test with pytest |
| 131 | + run: | |
| 132 | + cd ./dist/blosc2-*/ |
| 133 | + PYTHONPATH=. pytest |
| 134 | +
|
| 135 | +
|
| 136 | +
|
| 137 | +
|
| 138 | + upload_pypi: |
| 139 | + needs: [ build_wheels, build_sdist ] # last but not least |
| 140 | + runs-on: ubuntu-latest |
| 141 | + # if: startsWith(github.event.ref, 'refs/tags') |
| 142 | + steps: |
| 143 | + - uses: actions/download-artifact@v2 |
| 144 | + with: |
| 145 | + name: artifact |
| 146 | + path: dist |
| 147 | + |
| 148 | + - uses: pypa/gh-action-pypi-publish@master |
| 149 | + with: |
| 150 | + user: __token__ |
| 151 | + password: ${{ secrets.blosc_pypi_secret }} |
0 commit comments