From 916b5fcbf132b792955d92951fedad892f0acd34 Mon Sep 17 00:00:00 2001 From: Sean McLaughlin Date: Thu, 6 Feb 2025 14:40:40 -0800 Subject: [PATCH] CI: Make a wheel --- .github/workflows/ci.yml | 16 +++++++++++++--- bin/make-wheel | 10 +++++++++- interop/MANIFEST.in | 2 +- interop/pyproject.toml | 13 +++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7dd32cb..5df3735 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: ["main"] + branches: ["**"] # For now, let's build all branches. Roll this back if it gets too slow or we exhaust our quota. pull_request: branches: ["**"] # * does not match '/' workflow_dispatch: # For manually triggering a build: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_dispatch @@ -12,9 +12,10 @@ jobs: strategy: matrix: # We mainly care about hardware rather than OS - # macos-13 is x86. All later ones are arm64 + # macos-13 is x86. This one doesn't work for some reason. + # macos-latest is arm64 # ubuntu-latest is x64 - os: [macos-13, macos-latest, ubuntu-latest] + os: [macos-latest, ubuntu-latest] runs-on: ${{ matrix.os }} @@ -41,3 +42,12 @@ jobs: working-directory: ./interop run: | pytest + - name: Make a wheel + # https://github.com/pypa/cibuildwheel + run: | + pip install cibuildwheel + bin/make-wheel + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl diff --git a/bin/make-wheel b/bin/make-wheel index ead4f3a..c394072 100755 --- a/bin/make-wheel +++ b/bin/make-wheel @@ -16,7 +16,15 @@ cp $ROOT/interop/pyproject.toml $WHEEL_DIR cp $ROOT/interop/MANIFEST.in $WHEEL_DIR cd $WHEEL_DIR -python -m build + +if [ -z "${GITHUB_RUN_ID+x}" ]; then + echo "Building wheel locally" + python -m build -w +else + # https://github.com/pypa/cibuildwheel + echo "Building wheel via GitHub Actions" + python -m cibuildwheel --output-dir $WHEEL_DIR/wheelhouse +fi # To upload the wheel, with the proper token in ~/.pypirc, run # diff --git a/interop/MANIFEST.in b/interop/MANIFEST.in index 944d6af..d85df01 100644 --- a/interop/MANIFEST.in +++ b/interop/MANIFEST.in @@ -1 +1 @@ -include klr/bin/* +include bin/* diff --git a/interop/pyproject.toml b/interop/pyproject.toml index 65cec98..4fc2c54 100644 --- a/interop/pyproject.toml +++ b/interop/pyproject.toml @@ -27,5 +27,18 @@ testpaths = [ "test", ] +# NB: All this setuptools stuff took about 1000 hours to figure out so never delete this. +[tool.setuptools] +# This makes it ok for there to be both klr and wheelhouse (where we generates wheels on github actions) in the same directory +packages = ["klr"] +# This tricks setuptools into knowing this is a binary wheel +ext-modules = [ + {name = "klr", sources = []} +] + +[tool.setuptools.package-data] +# This part is essential to get the binary bin/klr included in the wheel +klr = ["bin/klr"] + [project.urls] Repository = "https://github.com/leanprover/KLR"