|
6 | 6 | - python-v* |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - create_macos_and_windows_wheels: |
10 | | - name: Wheels for Python ${{ matrix.python-version }} / ${{ matrix.os }} |
11 | | - strategy: |
12 | | - matrix: |
13 | | - os: [macos-latest, windows-latest] |
14 | | - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] |
15 | | - architecture: [x86, x64] |
16 | | - exclude: |
17 | | - - os: macos-latest |
18 | | - architecture: x86 |
19 | | - - os: windows-latest |
20 | | - # TODO: Re-enable windows 32bits |
21 | | - architecture: x86 |
22 | | - runs-on: ${{ matrix.os }} |
23 | | - steps: |
24 | | - - uses: actions/checkout@v2 |
25 | | - - uses: actions/setup-python@v2 |
26 | | - with: |
27 | | - python-version: ${{ matrix.python-version }} |
28 | | - architecture: ${{ matrix.architecture }} |
29 | | - - uses: actions-rs/toolchain@v1 |
30 | | - with: |
31 | | - profile: minimal |
32 | | - toolchain: stable |
33 | | - override: true |
34 | | - - name: Install Tox |
35 | | - run: pip install tox |
36 | | - - name: Build wheel |
37 | | - working-directory: ./bindings/python |
38 | | - run: tox -e build-wheel |
39 | | - - uses: actions/upload-artifact@v2 |
40 | | - with: |
41 | | - name: Distribution Artifacts |
42 | | - path: bindings/python/dist/ |
43 | | - |
44 | | - create_wheels_manylinux: |
45 | | - name: Wheels for Python ${{ matrix.PYTHON_IMPLEMENTATION_ABI }} / Linux |
| 9 | + wheels: |
| 10 | + name: "Create wheels for ${{ matrix.BUILD.NAME }}" |
| 11 | + runs-on: ${{ matrix.BUILD.OS }} |
46 | 12 | strategy: |
47 | 13 | fail-fast: false |
48 | 14 | matrix: |
49 | | - # List of the language-implementation API pairs to publish wheels for |
50 | | - # The list of supported is obtainable by running `docker run quay.io/pypa/manylinux2014_x86_64 ls /opt/python` |
51 | | - PYTHON_IMPLEMENTATION_ABI: [cp36-cp36m, cp37-cp37m, cp38-cp38, cp39-cp39, cp310-cp310] |
52 | | - runs-on: ubuntu-latest |
53 | | - container: quay.io/pypa/manylinux2014_x86_64 # Builds wheels on CentOS 7 (supported until 2024) |
| 15 | + BUILD: |
| 16 | + - NAME: "Linux x86_64 manylinux" |
| 17 | + OS: "ubuntu-20.04" |
| 18 | + ARCH: "x86_64" |
| 19 | + CIBW_BUILD: "*-manylinux*" |
| 20 | + RUST_TOOLCHAIN: "x86_64-unknown-linux-gnu" |
| 21 | + - NAME: "Linux aarch64 manylinux" |
| 22 | + OS: "ubuntu-20.04" |
| 23 | + ARCH: "aarch64" |
| 24 | + CIBW_BUILD: "*-manylinux*" |
| 25 | + RUST_TOOLCHAIN: "aarch64-unknown-linux-gnu" |
| 26 | + - NAME: "Linux x86_64 musllinux" |
| 27 | + OS: "ubuntu-20.04" |
| 28 | + ARCH: "x86_64" |
| 29 | + CIBW_BUILD: "*-musllinux*" |
| 30 | + RUST_TOOLCHAIN: "x86_64-unknown-linux-musl" |
| 31 | + - NAME: "Linux aarch64 musllinux" |
| 32 | + OS: "ubuntu-20.04" |
| 33 | + ARCH: "aarch64" |
| 34 | + CIBW_BUILD: "*-musllinux*" |
| 35 | + RUST_TOOLCHAIN: "aarch64-unknown-linux-musl" |
| 36 | + - NAME: "macOS x86_64" |
| 37 | + OS: "macos-11" |
| 38 | + ARCH: "x86_64" |
| 39 | + RUST_TOOLCHAIN: "x86_64-apple-darwin" |
| 40 | + - NAME: "macOS arm64" |
| 41 | + OS: "macos-11" |
| 42 | + ARCH: "arm64" |
| 43 | + RUST_TOOLCHAIN: "aarch64-apple-darwin" |
| 44 | + - NAME: "Windows x86_64" |
| 45 | + OS: "windows-2019" |
| 46 | + ARCH: "AMD64" |
| 47 | + RUST_TOOLCHAIN: "x86_64-pc-windows-msvc" |
| 48 | + - NAME: "Windows i686" |
| 49 | + OS: "windows-2019" |
| 50 | + ARCH: "x86" |
| 51 | + RUST_TOOLCHAIN: "i686-pc-windows-msvc" |
54 | 52 | env: |
55 | | - # Variable needed for PyO3 to properly identify the python interpreter |
56 | | - PYTHON_SYS_EXECUTABLE: /opt/python/${{ matrix.PYTHON_IMPLEMENTATION_ABI }}/bin/python |
| 53 | + # Install Rust toolchain inside the container |
| 54 | + CIBW_BEFORE_ALL: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -t ${{ matrix.BUILD.RUST_TOOLCHAIN }} -y --profile minimal" |
| 55 | + CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"' |
| 56 | + CIBW_BUILD: ${{ matrix.BUILD.CIBW_BUILD }} |
57 | 57 | steps: |
58 | 58 | - uses: actions/checkout@v2 |
59 | | - - name: Install/Update OpenSSL |
60 | | - run: | |
61 | | - retryCount=0 |
62 | | - # yum install seems to be flakey (due to network timeouts) |
63 | | - # retry up to 5 times with a 10s sleep in case of failure |
64 | | - until yum install openssl-devel --assumeyes --noplugins; do |
65 | | - # For some reason the install has failed |
66 | | - if [ ${retryCount} -eq 5 ]; then |
67 | | - false |
68 | | - else |
69 | | - retryCount=$((${retryCount}+1)) |
70 | | - fi |
71 | | - sleep 10 |
72 | | - done |
73 | | - - uses: actions-rs/toolchain@v1 |
| 59 | + - uses: actions/setup-python@v2 |
| 60 | + - name: Setup QEMU |
| 61 | + # QEMU is needed for building aarch64 wheels on Linux |
| 62 | + if: ${{ matrix.BUILD.ARCH == 'aarch64' && runner.os == 'Linux' }} |
| 63 | + uses: docker/setup-qemu-action@v1 |
74 | 64 | with: |
75 | | - profile: minimal |
76 | | - toolchain: stable |
77 | | - override: true |
78 | | - - name: Install Tox |
79 | | - run: ${{ env.PYTHON_SYS_EXECUTABLE }} -m pip install tox |
80 | | - - name: Build wheel |
81 | | - working-directory: ./bindings/python |
82 | | - run: | |
83 | | - ${{ env.PYTHON_SYS_EXECUTABLE }} -m tox -e build-wheel |
84 | | - # Ensure that the wheel is tagged as manylinux2014 platform |
85 | | - auditwheel repair \ |
86 | | - --wheel-dir=./dist \ |
87 | | - --plat manylinux2014_x86_64 \ |
88 | | - ./dist/css_inline-*-${{ matrix.PYTHON_IMPLEMENTATION_ABI }}-linux_x86_64.whl |
89 | | - # Remove `linux_x86_64` tagged wheels as they are not supported by https://pypi.org |
90 | | - # Example https://github.com/Stranger6667/jsonschema-rs/runs/766075274 |
91 | | - rm ./dist/css_inline-*-${{ matrix.PYTHON_IMPLEMENTATION_ABI }}-linux_x86_64.whl |
| 65 | + platforms: all |
| 66 | + - name: Install cibuildwheel |
| 67 | + run: python -m pip install cibuildwheel |
| 68 | + - name: Build wheels |
| 69 | + run: python -m cibuildwheel bindings/python --output-dir wheelhouse |
| 70 | + env: |
| 71 | + CIBW_ARCHS: ${{ matrix.BUILD.ARCH }} |
92 | 72 | - uses: actions/upload-artifact@v2 |
93 | 73 | with: |
94 | 74 | name: Distribution Artifacts |
95 | | - path: bindings/python/dist/ |
| 75 | + path: wheelhouse/*.whl |
96 | 76 |
|
97 | | - create_source_dist: |
| 77 | + sdist: |
98 | 78 | name: Create sdist package |
99 | | - runs-on: ubuntu-latest |
| 79 | + runs-on: ubuntu-20.04 |
100 | 80 | steps: |
101 | 81 | - uses: actions/checkout@v2 |
102 | 82 | - uses: actions/setup-python@v2 |
103 | 83 | with: |
104 | | - python-version: 3.7 |
105 | | - - uses: actions-rs/toolchain@v1 |
106 | | - with: |
107 | | - profile: minimal |
108 | | - toolchain: stable |
109 | | - override: true |
| 84 | + python-version: 3.9 |
110 | 85 | - name: Install Tox |
111 | 86 | run: pip install tox |
| 87 | + - run: mkdir wheelhouse |
112 | 88 | - name: Build sdist |
| 89 | + run: tox -e build-sdist && mv dist/css_inline-*.tar.gz ../../wheelhouse |
113 | 90 | working-directory: ./bindings/python |
114 | | - run: tox -e build-sdist |
115 | 91 | - uses: actions/upload-artifact@v2 |
116 | 92 | with: |
117 | 93 | name: Distribution Artifacts |
118 | | - path: bindings/python/dist/ |
| 94 | + path: wheelhouse/*.tar.gz |
119 | 95 |
|
120 | 96 | upload_to_pypi: |
121 | 97 | needs: |
122 | | - - create_macos_and_windows_wheels |
123 | | - - create_wheels_manylinux |
124 | | - - create_source_dist |
| 98 | + - wheels |
| 99 | + - sdist |
125 | 100 | name: Upload Artifacts to PyPi |
126 | | - runs-on: ubuntu-latest |
| 101 | + runs-on: ubuntu-20.04 |
127 | 102 | steps: |
128 | 103 | - uses: actions/download-artifact@v2 |
129 | 104 | with: |
130 | | - name: Distribution Artifacts |
131 | | - path: bindings/python/dist/ |
| 105 | + name: Download Artifacts |
| 106 | + path: wheelhouse/ |
132 | 107 | - name: Publish distribution package to PyPI |
133 | | - uses: pypa/gh-action-pypi-publish@v1.2.2 |
| 108 | + uses: pypa/gh-action-pypi-publish@v1 |
134 | 109 | with: |
135 | 110 | user: ${{ secrets.PYPI_USERNAME }} |
136 | 111 | password: ${{ secrets.PYPI_PASSWORD }} |
137 | | - packages_dir: bindings/python/dist/ |
| 112 | + packages_dir: wheelhouse/ |
0 commit comments