| 1 |
# Runs CI tests and generates wheels on the following platforms: |
| 2 |
# * Linux |
| 3 |
# * macOS |
| 4 |
# * Windows |
| 5 |
# |
| 6 |
# Useful URLs: |
| 7 |
# * https://github.com/pypa/cibuildwheel |
| 8 |
# * https://github.com/actions/checkout |
| 9 |
# * https://github.com/actions/setup-python |
| 10 |
# * https://github.com/actions/upload-artifact |
| 11 |
|
| 12 |
on: [push, pull_request] |
| 13 |
name: build |
| 14 |
concurrency: |
| 15 |
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }} |
| 16 |
cancel-in-progress: true |
| 17 |
jobs: |
| 18 |
|
| 19 |
# Run tests on Linux, macOS, Windows |
| 20 |
tests: |
| 21 |
name: "tests, ${{ matrix.os }}, ${{ matrix.arch }}" |
| 22 |
runs-on: ${{ matrix.os }} |
| 23 |
timeout-minutes: 20 |
| 24 |
strategy: |
| 25 |
fail-fast: false |
| 26 |
matrix: |
| 27 |
include: |
| 28 |
- { os: ubuntu-latest, arch: x86_64 } |
| 29 |
- { os: ubuntu-latest, arch: i686 } |
| 30 |
- { os: ubuntu-24.04-arm, arch: aarch64 } |
| 31 |
- { os: macos-13, arch: x86_64 } |
| 32 |
- { os: macos-14, arch: arm64 } |
| 33 |
- { os: windows-2025, arch: AMD64 } |
| 34 |
- { os: windows-2025, arch: x86 } |
| 35 |
- { os: windows-11-arm, arch: ARM64 } |
| 36 |
steps: |
| 37 |
- uses: actions/checkout@v5 |
| 38 |
|
| 39 |
# Only install Python 3.8 on macOS ARM64 for universal2 support |
| 40 |
- name: "Install Python 3.8 on macOS ARM64" |
| 41 |
if: runner.os == 'macOS' && runner.arch == 'ARM64' |
| 42 |
uses: actions/setup-python@v5 |
| 43 |
with: |
| 44 |
python-version: 3.8 |
| 45 |
|
| 46 |
- uses: actions/setup-python@v5 |
| 47 |
with: |
| 48 |
python-version: 3.11 |
| 49 |
|
| 50 |
- name: Build wheels + run tests |
| 51 |
uses: pypa/[email protected] |
| 52 |
env: |
| 53 |
CIBW_ARCHS: "${{ matrix.arch }}" |
| 54 |
CIBW_ENABLE: "${{ startsWith(github.ref, 'refs/tags/') && '' || 'cpython-prerelease' }}" |
| 55 |
|
| 56 |
- name: Upload wheels |
| 57 |
uses: actions/upload-artifact@v4 |
| 58 |
with: |
| 59 |
name: wheels-${{ matrix.os }}-${{ matrix.arch }} |
| 60 |
path: wheelhouse |
| 61 |
|
| 62 |
- name: Generate source distribution (.tar.gz) |
| 63 |
if: matrix.os == 'ubuntu-latest' |
| 64 |
run: | |
| 65 |
make generate-manifest |
| 66 |
python setup.py sdist |
| 67 |
mv dist/psutil*.tar.gz wheelhouse/ |
| 68 |
|
| 69 |
# Test python 2.7 fallback installation message produced by setup.py |
| 70 |
py2-fallback: |
| 71 |
name: py2.7 setup.py check |
| 72 |
runs-on: ubuntu-24.04 |
| 73 |
timeout-minutes: 20 |
| 74 |
strategy: |
| 75 |
fail-fast: false |
| 76 |
steps: |
| 77 |
- uses: actions/checkout@v5 |
| 78 |
- uses: LizardByte/actions/actions/setup_python@master |
| 79 |
with: |
| 80 |
python-version: 2.7 |
| 81 |
- run: python scripts/internal/test_python2_setup_py.py |
| 82 |
|
| 83 |
linters: |
| 84 |
runs-on: ubuntu-latest |
| 85 |
steps: |
| 86 |
- uses: actions/checkout@v5 |
| 87 |
- uses: actions/setup-python@v5 |
| 88 |
with: |
| 89 |
python-version: 3.x |
| 90 |
- name: "Run linters" |
| 91 |
run: | |
| 92 |
make lint-ci |
| 93 |
|
| 94 |
# Produce wheels as artifacts. |
| 95 |
upload-wheels: |
| 96 |
needs: [tests] |
| 97 |
runs-on: ubuntu-latest |
| 98 |
steps: |
| 99 |
- uses: actions/upload-artifact/merge@v4 |
| 100 |
with: |
| 101 |
name: wheels |
| 102 |
pattern: wheels-* |
| 103 |
separate-directories: false |
| 104 |
delete-merged: true |
| 105 |
|
| 106 |
# Check sanity of .tar.gz + wheel files |
| 107 |
check-dist: |
| 108 |
needs: [upload-wheels] |
| 109 |
runs-on: ubuntu-latest |
| 110 |
steps: |
| 111 |
- uses: actions/checkout@v5 |
| 112 |
- uses: actions/setup-python@v5 |
| 113 |
with: |
| 114 |
python-version: 3.x |
| 115 |
- uses: actions/download-artifact@v4 |
| 116 |
with: |
| 117 |
name: wheels |
| 118 |
path: wheelhouse |
| 119 |
- run: | |
| 120 |
python scripts/internal/print_hashes.py wheelhouse/ |
| 121 |
pipx run twine check --strict wheelhouse/* |
| 122 |
pipx run abi3audit --verbose --strict wheelhouse/*-abi3-*.whl |