diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a3f6763..cb44e90 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,14 +35,26 @@ jobs: sudo apt-get update sudo apt-get install -y musl-tools - - name: Build init binary - run: | - make - - name: Build sdist and wheel run: | poetry build + # The build script makes the wheel interpreter and platform specific + # (cp311-cp311-linux_x86_64), which PyPI rejects. The only native code + # is the static kerf-init, so the wheel runs on any Python 3 and libc. + - name: Retag wheel for PyPI + run: | + file src/kerf/data/kerf-init | grep -q "statically linked" + pip install wheel auditwheel + python -m wheel tags --remove --python-tag py3 --abi-tag none \ + --platform-tag manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64 \ + dist/*.whl + auditwheel show dist/*.whl + + - name: Check the sdist builds a wheel + run: | + pip wheel --no-deps -w /tmp/sdist-wheel dist/*.tar.gz + - name: Upload distributions uses: actions/upload-artifact@v4 with: diff --git a/README.md b/README.md index 2ab0960..c0792c2 100644 --- a/README.md +++ b/README.md @@ -322,7 +322,9 @@ pip install kerf-multikernel # Or isolated with pipx, avoiding conflicts with other packages pipx install kerf-multikernel -# From source (recommended for development) +# From source (recommended for development). Installing builds the +# static kerf-init with musl-gcc (e.g. apt install musl-tools), so +# rerunning pip install after a pull also picks up kerf-init changes. git clone https://github.com/multikernel/kerf.git cd kerf # Installs 'kerf' command to ~/.local/bin/kerf diff --git a/build.py b/build.py new file mode 100644 index 0000000..cc95756 --- /dev/null +++ b/build.py @@ -0,0 +1,21 @@ +# Copyright 2026 Multikernel Technologies, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Poetry build script: rebuild kerf-init so a wheel never ships a stale one. +""" + +import subprocess + +subprocess.run(["make", "init"], check=True) diff --git a/pyproject.toml b/pyproject.toml index d2cd7e6..2ef6a24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,9 +10,17 @@ authors = ["Cong Wang"] readme = "README.md" packages = [{include = "kerf", from = "src"}] include = [ - { path = "src/kerf/data/kerf-init", format = ["sdist", "wheel"] }, + { path = "src/kerf/data/kerf-init", format = ["wheel"] }, + { path = "Makefile", format = ["sdist"] }, + { path = "src/init/Makefile", format = ["sdist"] }, + { path = "src/init/*.c", format = ["sdist"] }, + { path = "src/init/*.h", format = ["sdist"] }, ] +[tool.poetry.build] +script = "build.py" +generate-setup-file = false + [tool.poetry.dependencies] python = "^3.9" pylibfdt = "^1.7.0"