From 9eaee1988ece037da8d112520235fc670f10e1b5 Mon Sep 17 00:00:00 2001 From: Fanwang Meng Date: Thu, 12 Dec 2024 21:50:36 -0500 Subject: [PATCH 1/3] Use cibuildwheel for building cross-platform wheels --- .github/workflows/pypi_release.yaml | 115 ++++++++++++++++------------ pyproject.toml | 11 +-- 2 files changed, 70 insertions(+), 56 deletions(-) diff --git a/.github/workflows/pypi_release.yaml b/.github/workflows/pypi_release.yaml index fc3d7e00..3e48755c 100644 --- a/.github/workflows/pypi_release.yaml +++ b/.github/workflows/pypi_release.yaml @@ -22,62 +22,77 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - # os: [ubuntu-latest, macos-latest] + # os: [ubuntu-latest, windows-latest, macos-13, macos-14] # python-version: ["3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest] python-version: ["3.12"] steps: - # # TODO: Add C++ compliers - # # Fetch CUDA toolkit using Jimver/cuda-toolkit - # - name: Fetch CUDA toolkit - # uses: Jimver/cuda-toolkit@v0.2.18 - # id: cuda-toolkit - # with: - # cuda: "12.1.0" - - # - name: Check nvcc version - # run: nvcc -V - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v5 - # with: - # python-version: "3.12" + # - name: Set up Python + # uses: actions/setup-python@v5 + # # with: + # # python-version: "3.12" + # with: + # python-version: ${{ matrix.python-version }} + + # - name: Install system dependencies (Ubuntu) + # if: runner.os == 'Linux' + # run: | + # sudo apt-get update + # sudo apt-get install -y make gcc g++ python3-dev + + # - name: Install system dependencies (macOS) + # if: runner.os == 'macOS' + # run: | + # brew install gcc make + + # - name: Install development and distributions version + # run: | + # pip install --upgrade pip + # pip install -v . + # pip install pytest build cibuildwheel + + # - name: Build Source Distribution + # run: | + # # make + # # make test + # # python -m build --sdist + # cibuildwheel --output-dir dist + + - name: build wheels with cibuildwheel + uses: pypa/cibuildwheel@v2.22.0 + # env: + # CIBW_SOME_OPTION: value + # ... with: - python-version: ${{ matrix.python-version }} - - - name: Install system dependencies (Ubuntu) - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y make gcc g++ python3-dev - - - name: Install system dependencies (macOS) - if: runner.os == 'macOS' - run: | - brew install gcc make - - - name: Install development and distributions version - run: | - pip install --upgrade pip - pip install -v . - pip install pytest build - - - name: Build Source Distribution - run: | - make - make test - python -m build --sdist + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" - name: Store the distribution packages uses: actions/upload-artifact@v4 with: - name: python-package-distributions - path: dist/ + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: python -m build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz publish-to-pypi: name: Publish Python distribution to PyPI @@ -96,8 +111,10 @@ jobs: - name: Download all the dists uses: actions/download-artifact@v4 with: - name: python-package-distributions - path: dist/ + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 env: @@ -118,8 +135,10 @@ jobs: - name: Download all the dists uses: actions/download-artifact@v4 with: - name: python-package-distributions - path: dist/ + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true - name: Sign the dists with Sigstore uses: sigstore/gh-action-sigstore-python@v3.0.0 with: @@ -160,8 +179,10 @@ jobs: - name: Download all the dists uses: actions/download-artifact@v4 with: - name: python-package-distributions - path: dist/ + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true - name: Publish distribution to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/pyproject.toml b/pyproject.toml index 342bd775..aadedb08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,8 @@ requires = [ "setuptools_scm>=8", # For version management "setuptools>=61.0.0", # For building the package "pytest>=8.0.0", # For running tests + "cibuildwheel>=2.0.0", + "wheel", ] # build-backend = "scikit_build_core.build" build-backend = "setuptools.build_meta" @@ -92,15 +94,6 @@ packages = [ "data/*.npz" # Compressed NumPy data files ] -# Build configuration -[tool.scikit-build] -sdist.exclude = [ - ".github", - "tests/data/*.fchk", - "examples/*.fchk" -] -metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" - # Version management configuration [tool.setuptools_scm] # Enable setuptools-scm for version management From 6f8f3787dcd26e5832cac8ab7628299ae425d401 Mon Sep 17 00:00:00 2001 From: Fanwang Meng Date: Thu, 12 Dec 2024 21:52:09 -0500 Subject: [PATCH 2/3] Fix syntax error --- .github/workflows/pypi_release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pypi_release.yaml b/.github/workflows/pypi_release.yaml index 3e48755c..4b1077a7 100644 --- a/.github/workflows/pypi_release.yaml +++ b/.github/workflows/pypi_release.yaml @@ -69,10 +69,10 @@ jobs: # env: # CIBW_SOME_OPTION: value # ... - with: - # package-dir: . - # output-dir: wheelhouse - # config-file: "{package}/pyproject.toml" + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" - name: Store the distribution packages uses: actions/upload-artifact@v4 From b47b8bcb843f164a41917d55dfff644921c4b109 Mon Sep 17 00:00:00 2001 From: Fanwang Meng Date: Thu, 12 Dec 2024 21:54:37 -0500 Subject: [PATCH 3/3] Fix source distribution built --- .github/workflows/pypi_release.yaml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pypi_release.yaml b/.github/workflows/pypi_release.yaml index 4b1077a7..b1674cee 100644 --- a/.github/workflows/pypi_release.yaml +++ b/.github/workflows/pypi_release.yaml @@ -85,9 +85,17 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Build sdist - run: python -m build --sdist + - name: Install development and distributions version + run: | + pip install --upgrade pip + pip install -v . + pip install pytest build + + - name: Build Source Distribution + run: | + make + make test + python -m build --sdist - uses: actions/upload-artifact@v4 with: