|
10 | 10 | jobs:
|
11 | 11 | build-wheels:
|
12 | 12 | runs-on: ${{ matrix.os }}
|
13 |
| - name: ${{ matrix.name }} |
| 13 | + name: ${{ matrix.os }} |
14 | 14 | strategy:
|
15 | 15 | matrix:
|
16 |
| - include: |
17 |
| - - name: x86_64 macOS |
18 |
| - os: macos-11 |
19 |
| - platform-name: macosx-10.9-x86_64 |
20 |
| - - name: M1 macOS |
21 |
| - os: macos-11 |
22 |
| - platform-name: macosx-11.0-arm64 |
23 |
| - # TODO: add a Windows builder |
| 16 | + # TODO: add windows builder |
| 17 | + os: [ubuntu-20.04, macos-11] |
| 18 | + |
24 | 19 | steps:
|
25 | 20 | - uses: actions/checkout@v3
|
26 | 21 | with:
|
27 | 22 | fetch-depth: 0
|
| 23 | + |
28 | 24 | - name: Set up Python
|
29 | 25 | uses: actions/setup-python@v4
|
30 | 26 | with:
|
31 | 27 | python-version: "3.10"
|
32 |
| - - name: build wheel |
33 |
| - env: |
34 |
| - MACOS_DEPLOYMENT_TARGET: "11.0" |
35 |
| - run: | |
36 |
| - python -m pip install wheel cmake torch |
37 |
| - python setup.py bdist_wheel --plat-name ${{ matrix.platform-name }} |
38 |
| - cd sphericart-torch |
39 |
| - python setup.py bdist_wheel --plat-name ${{ matrix.platform-name }} |
40 | 28 |
|
41 |
| - # build sphericart-torch wheels on CI, but do no include them in the |
42 |
| - # uploaded wheels (see justification below in the Linux builder) |
43 |
| - # mv dist/*.whl ../dist/ |
44 |
| - - uses: actions/upload-artifact@v3 |
45 |
| - with: |
46 |
| - name: wheels |
47 |
| - path: dist/*.whl |
48 |
| - - name: upload wheel to GitHub release |
49 |
| - if: startsWith(github.ref, 'refs/tags/') |
50 |
| - uses: softprops/action-gh-release@v1 |
51 |
| - with: |
52 |
| - files: dist/*.whl |
53 |
| - env: |
54 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + - name: Install cibuildwheel |
| 30 | + run: python -m pip install cibuildwheel build |
55 | 31 |
|
56 |
| - build-manylinux-wheels: |
57 |
| - runs-on: ubuntu-20.04 |
58 |
| - # TODO: add other arch for linux? |
59 |
| - name: x86_64 manylinux |
60 |
| - steps: |
61 |
| - - uses: actions/checkout@v3 |
62 |
| - with: |
63 |
| - fetch-depth: 0 |
64 |
| - - name: build wheel in docker |
| 32 | + - name: Build sphericart wheels |
65 | 33 | run: |
|
66 |
| - docker run --rm -v $(pwd):/code quay.io/pypa/manylinux2014_x86_64 bash -c "cd /code && /opt/python/cp38-cp38/bin/python -m pip wheel --no-deps -w dist . --verbose" |
67 |
| - docker run --rm -v $(pwd):/code quay.io/pypa/manylinux2014_x86_64 bash -c "cd /code/sphericart-torch && /opt/python/cp38-cp38/bin/python -m pip wheel --no-deps -w dist . --verbose --extra-index-url=https://download.pytorch.org/whl/cpu" |
68 |
| - - name: run auditwheel in docker |
| 34 | + # ensure we build the wheel from the sdist, not the checkout |
| 35 | + python -m build --sdist . --outdir dist |
| 36 | + python -m cibuildwheel dist/*.tar.gz --output-dir dist |
| 37 | + env: |
| 38 | + # build wheels on CPython 3.10 |
| 39 | + CIBW_BUILD: cp310-* |
| 40 | + # skip musl and 32-bit builds |
| 41 | + CIBW_SKIP: "*-musllinux* *-win32 *-manylinux_i686" |
| 42 | + # on macOS, build both Intel & Apple Silicon versions |
| 43 | + CIBW_ARCHS_MACOS: x86_64 arm64 |
| 44 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 |
| 45 | + |
| 46 | + - name: Build sphericart-torch wheels |
69 | 47 | run: |
|
70 |
| - docker run --rm -v $(pwd):/code quay.io/pypa/manylinux2014_x86_64 bash -c "auditwheel repair /code/dist/*.whl -w /code/dist" |
71 |
| - docker run --rm -v $(pwd):/code quay.io/pypa/manylinux2014_x86_64 bash -c "auditwheel repair --exclude libtorch.so --exclude libtorch_cpu.so --exclude libc10.so /code/sphericart-torch/dist/*.whl -w /code/dist" |
72 |
| - - name: remove wheel with wrong tag |
73 |
| - run: sudo rm dist/*linux_x86_64.whl |
74 |
| - - name: remove sphericart-torch wheels |
75 |
| - # these wheels are only built for one Python version and one PyTorch |
76 |
| - # version, so we should not upload them since they won't be usable by |
77 |
| - # most users |
78 |
| - run: sudo rm dist/sphericart_torch*.whl |
| 48 | + # ensure we build the wheel from the sdist, not the checkout |
| 49 | + python -m build --sdist sphericart-torch --outdir sphericart-torch/dist |
| 50 | + python -m cibuildwheel sphericart-torch/dist/*.tar.gz --output-dir sphericart-torch/dist |
| 51 | + env: |
| 52 | + CIBW_BUILD: cp310-* |
| 53 | + CIBW_SKIP: "*-musllinux* *-win32 *-manylinux_i686" |
| 54 | + # we can not build wheels for macos-arm64, since the host is always |
| 55 | + # x86_64, and we assume we can link against the host version of libtorch |
| 56 | + CIBW_ARCHS_MACOS: x86_64 |
| 57 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 |
| 58 | + # Use the CPU only version of torch when building/running the code |
| 59 | + CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu |
| 60 | + # do not complain for missing libtorch.so in sphericart-torch wheel |
| 61 | + CIBW_REPAIR_WHEEL_COMMAND_MACOS: | |
| 62 | + delocate-wheel --ignore-missing-dependencies --require-archs {delocate_archs} -w {dest_dir} -v {wheel} |
| 63 | + CIBW_REPAIR_WHEEL_COMMAND_LINUX: | |
| 64 | + auditwheel repair --exclude libtorch.so --exclude libtorch_cpu.so --exclude libc10.so -w {dest_dir} {wheel} |
| 65 | +
|
79 | 66 | - uses: actions/upload-artifact@v3
|
80 | 67 | with:
|
81 | 68 | name: wheels
|
82 | 69 | path: dist/*.whl
|
| 70 | + |
83 | 71 | - name: upload wheel to GitHub release
|
84 | 72 | if: startsWith(github.ref, 'refs/tags/')
|
85 | 73 | uses: softprops/action-gh-release@v1
|
|
0 commit comments