Skip to content

Update cibuildwheel to 2.17.0 #2799

Update cibuildwheel to 2.17.0

Update cibuildwheel to 2.17.0 #2799

Workflow file for this run

name: Build wheels
on: [push, pull_request, workflow_dispatch]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
generate_wheels_matrix:
name: Generate wheels matrix
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v4
- name: Checkout mypy
shell: bash
# use a commit hash checked into a file to get the mypy revision to build.
# submodules prove problematic since .git is outside cibuildwheel's manylinux container
run: |
git clone https://github.com/python/mypy.git --recurse-submodules
git -C mypy checkout $(cat mypy_commit)
- name: Install cibuildwheel and pypyp
run: |
pipx install cibuildwheel==2.17.0
pipx install pypyp==1
- id: set-matrix
run: |
MATRIX=$(
{
cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform linux mypy \
| pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \
&& cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform macos mypy \
| pyp 'json.dumps({"only": x, "os": "macos-14"})' \
&& cibuildwheel --config-file=cibuildwheel.toml --print-build-identifiers --platform windows mypy \
| pyp 'json.dumps({"only": x, "os": "windows-latest"})'
} | pyp 'json.dumps(list(map(json.loads, lines)))'
)
echo "include=$MATRIX" | tee -a $GITHUB_OUTPUT
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ARCHS_WINDOWS: AMD64
build_wheels:
name: Build ${{ matrix.only }}
needs: generate_wheels_matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate_wheels_matrix.outputs.include) }}
steps:
- uses: actions/checkout@v4
- name: Checkout mypy
shell: bash
# use a commit hash checked into a file to get the mypy revision to build.
# submodules prove problematic since .git is outside cibuildwheel's manylinux container
run: |
git clone https://github.com/python/mypy.git --recurse-submodules
git -C mypy checkout $(cat mypy_commit)
- uses: pypa/[email protected]
with:
config-file: cibuildwheel.toml
package-dir: mypy
only: ${{ matrix.only }}
- uses: actions/upload-artifact@v3
with:
name: dist
path: ./wheelhouse/*.whl
build_sdist_python_wheel:
name: sdist and python wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: "3.9"
- name: Checkout mypy
shell: bash
run: |
COMMIT=$(cat mypy_commit)
git clone https://github.com/python/mypy.git
cd mypy
git checkout $COMMIT
git submodule update --init --recursive
- name: Run check-manifest
run: |
cd mypy
pip install check-manifest
check-manifest -v
- name: Build sdist and wheel
run: |
cd mypy
pip install --upgrade setuptools build
python -m build
- uses: actions/upload-artifact@v3
with:
name: dist
path: |
mypy/dist/*.whl
mypy/dist/*.tar.gz
build_wasm_wheel:
name: WASM wheel for 3.10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: "3.10"
- uses: actions/setup-node@v3
with:
node-version: 18.5.0 # pyodide tests with this version
- name: Install emscripten
id: install_emsdk
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
# Version of Emscripten pyodide 0.21.0 uses.
./emsdk install 3.1.14
./emsdk activate 3.1.14
# We need the location of emscripten when we use pyodide-build
echo "EMSCRIPTEN_DIR=$(pwd)" >> $GITHUB_OUTPUT
- name: Checkout mypy
shell: bash
run: |
COMMIT=$(cat mypy_commit)
git clone https://github.com/python/mypy.git
cd mypy
git checkout $COMMIT
git submodule update --init --recursive
- name: Install pyodide-build
run: |
python -m pip install "pyodide-build==0.21.0"
- name: Build wasm wheels
env:
MYPY_USE_MYPYC: "1"
MYPYC_OPT_LEVEL: "3"
EMSCRIPTEN_DIR: ${{ steps.install_emsdk.outputs.EMSCRIPTEN_DIR }}
run: |
cd mypy
source $EMSCRIPTEN_DIR/emsdk_env.sh
pyodide build --exports pyinit
- name: Install pyodide for WASM test
run: |
npm install [email protected]
- name: Run WASM smoke test
run: |
node wasm_test.js
- uses: actions/upload-artifact@v3
with:
name: dist
path: |
mypy/dist/*.whl
release:
name: create release
needs: [build_wheels, build_sdist_python_wheel]
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Release
if: ${{ github.event_name != 'pull_request' }}
# https://github.com/actions/upload-release-asset/issues/47
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log('environment', process.versions);
console.log({ owner, repo, sha });
const release = await github.rest.repos.createRelease({
owner, repo,
// if GITHUB_REF just appears to be a branch, use tag-{commit} as the tag
tag_name: process.env.GITHUB_REF.includes("refs/heads/") ? "tag-" + sha : process.env.GITHUB_REF.split("/").pop(),
target_commitish: sha
});
console.log('created release', { release });
for (let file of await fs.readdir('dist')) {
console.log('uploading', file);
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./dist/${file}`)
});
}