|
5 | 5 | types: |
6 | 6 | - released |
7 | 7 | workflow_dispatch: |
| 8 | + inputs: |
| 9 | + build_x86_64: |
| 10 | + description: "Build x86_64 wheels" |
| 11 | + type: boolean |
| 12 | + default: true |
| 13 | + build_aarch64: |
| 14 | + description: "Build aarch64 wheels" |
| 15 | + type: boolean |
| 16 | + default: true |
8 | 17 |
|
9 | 18 | jobs: |
10 | 19 | build_wheel_linux: |
11 | 20 | runs-on: ubuntu-latest |
12 | 21 |
|
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + arch: [x86_64, aarch64] |
| 26 | + py: ['3.11', '3.12', '3.13', '3.14'] |
| 27 | + |
13 | 28 | steps: |
14 | | - - uses: actions/checkout@v4 |
| 29 | + - uses: actions/checkout@v5 |
| 30 | + |
| 31 | + - name: Decide whether to build |
| 32 | + id: decide |
| 33 | + shell: bash |
| 34 | + run: | |
| 35 | + should_build=false |
| 36 | +
|
| 37 | + if [ "${{ github.event_name }}" = "release" ]; then |
| 38 | + # On release: always build all matrix combinations |
| 39 | + should_build=true |
| 40 | + elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 41 | + if [ "${{ matrix.arch }}" = "x86_64" ] && [ "${{ inputs.build_x86_64 }}" = "true" ]; then |
| 42 | + should_build=true |
| 43 | + elif [ "${{ matrix.arch }}" = "aarch64" ] && [ "${{ inputs.build_aarch64 }}" = "true" ]; then |
| 44 | + should_build=true |
| 45 | + fi |
| 46 | + fi |
| 47 | +
|
| 48 | + echo "should_build=$should_build" >> "$GITHUB_OUTPUT" |
15 | 49 |
|
16 | 50 | - name: Set up QEMU |
| 51 | + if: ${{ steps.decide.outputs.should_build == 'true' }} |
17 | 52 | uses: docker/setup-qemu-action@v3 |
18 | 53 | with: |
19 | 54 | platforms: all |
20 | 55 |
|
21 | 56 | - name: Set up Docker Buildx |
| 57 | + if: ${{ steps.decide.outputs.should_build == 'true' }} |
22 | 58 | uses: docker/setup-buildx-action@v3 |
23 | 59 |
|
24 | | - - name: Build wheel for x86_64 |
| 60 | + - name: Build ${{ matrix.arch }} wheel for Python ${{ matrix.py }} |
| 61 | + if: ${{ steps.decide.outputs.should_build == 'true' }} |
25 | 62 | run: | |
26 | | - docker run --rm -v ${{ github.workspace }}:/project -w /project quay.io/pypa/manylinux2014_x86_64 bash -c " |
27 | | - yum install -y curl && \ |
28 | | - curl -Lo /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 && \ |
29 | | - chmod +x /usr/local/bin/bazel && \ |
30 | | - /opt/python/cp311-cp311/bin/pip install --upgrade pip setuptools wheel auditwheel && \ |
31 | | - ln -s /opt/python/cp311-cp311/bin/python3 /usr/local/bin/python3 && \ |
32 | | - cd pyscfadlib && \ |
33 | | - python3 build/build.py build --python_version=3.10 && \ |
34 | | - python3 build/build.py build --python_version=3.11 && \ |
35 | | - python3 build/build.py build --python_version=3.12 && \ |
36 | | - python3 build/build.py build --python_version=3.13 && \ |
37 | | - auditwheel repair dist/*.whl -w wheelhouse_x86_64/ && \ |
38 | | - rm -rf dist/ |
39 | | - " |
40 | | -
|
41 | | - - name: Upload x86_64 wheel |
42 | | - uses: actions/upload-artifact@v4 |
43 | | - with: |
44 | | - name: cuda_plugin_wheels_x86_64 |
45 | | - path: pyscfadlib/wheelhouse_x86_64/*.whl |
46 | | - overwrite: true |
| 63 | + ARCH=${{ matrix.arch }} |
| 64 | + PY=${{ matrix.py }} |
| 65 | + TAG=${PY/./} |
47 | 66 |
|
48 | | - - name: Build wheel for aarch64 |
49 | | - run: | |
50 | | - docker run --rm --platform linux/arm64 -v ${{ github.workspace }}:/project -w /project quay.io/pypa/manylinux2014_aarch64 bash -c " |
51 | | - yum install -y curl && \ |
52 | | - curl -Lo /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-arm64 && \ |
53 | | - chmod +x /usr/local/bin/bazel && \ |
54 | | - /opt/python/cp311-cp311/bin/pip install --upgrade pip setuptools wheel auditwheel && \ |
55 | | - ln -s /opt/python/cp311-cp311/bin/python3 /usr/local/bin/python3 && \ |
56 | | - cd pyscfadlib && \ |
57 | | - python3 build/build.py build --python_version=3.10 --target_cpu=aarch64 && \ |
58 | | - python3 build/build.py build --python_version=3.11 --target_cpu=aarch64 && \ |
59 | | - python3 build/build.py build --python_version=3.12 --target_cpu=aarch64 && \ |
60 | | - python3 build/build.py build --python_version=3.13 --target_cpu=aarch64 && \ |
61 | | - auditwheel repair dist/*.whl -w wheelhouse_aarch64/ |
62 | | - " |
63 | | -
|
64 | | - - name: Upload aarch64 wheel |
| 67 | + if [ "$ARCH" = "x86_64" ]; then |
| 68 | + IMAGE=quay.io/pypa/manylinux_2_28_x86_64 |
| 69 | + BAZEL_URL=https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 |
| 70 | + PLATFORM_ARG="" |
| 71 | + else |
| 72 | + IMAGE=quay.io/pypa/manylinux_2_28_aarch64 |
| 73 | + BAZEL_URL=https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-arm64 |
| 74 | + PLATFORM_ARG="--platform linux/arm64" |
| 75 | + fi |
| 76 | +
|
| 77 | + docker run --rm $PLATFORM_ARG \ |
| 78 | + -v ${{ github.workspace }}:/project \ |
| 79 | + -w /project \ |
| 80 | + "$IMAGE" \ |
| 81 | + bash -lc " |
| 82 | + yum install -y curl |
| 83 | + curl -Lo /usr/local/bin/bazel $BAZEL_URL |
| 84 | + chmod +x /usr/local/bin/bazel |
| 85 | +
|
| 86 | + /opt/python/cp${TAG}-cp${TAG}/bin/pip install --no-cache-dir --upgrade pip setuptools wheel auditwheel |
| 87 | + ln -sf /opt/python/cp${TAG}-cp${TAG}/bin/python3 /usr/local/bin/python3 |
| 88 | +
|
| 89 | + cd /project/pyscfadlib |
| 90 | +
|
| 91 | + if [ \"$ARCH\" = \"aarch64\" ]; then |
| 92 | + python3 build/build.py build --python_version=${PY} --target_cpu=aarch64 |
| 93 | + else |
| 94 | + python3 build/build.py build --python_version=${PY} |
| 95 | + fi |
| 96 | +
|
| 97 | + mkdir -p wheelhouse |
| 98 | + auditwheel repair dist/*cp${TAG}*.whl -w wheelhouse/ |
| 99 | + " |
| 100 | +
|
| 101 | + - name: Upload wheel |
| 102 | + if: ${{ steps.decide.outputs.should_build == 'true' }} |
65 | 103 | uses: actions/upload-artifact@v4 |
66 | 104 | with: |
67 | | - name: cuda_plugin_wheels_aarch64 |
68 | | - path: pyscfadlib/wheelhouse_aarch64/*.whl |
| 105 | + name: cuda_plugin_${{ matrix.arch }}_${{ matrix.py }} |
| 106 | + path: pyscfadlib/wheelhouse/*.whl |
69 | 107 | overwrite: true |
70 | 108 |
|
71 | 109 | publish_pypi_linux: |
72 | | - name: publish linux wheels to pypi |
73 | 110 | needs: build_wheel_linux |
| 111 | + if: always() |
74 | 112 | runs-on: ubuntu-latest |
75 | | - |
76 | 113 | environment: release |
77 | 114 | permissions: |
78 | 115 | id-token: write |
|
88 | 125 |
|
89 | 126 | - name: Publish to PyPI |
90 | 127 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 128 | + with: |
| 129 | + skip-existing: true |
0 commit comments