Skip to content

Commit 7bd21dc

Browse files
authored
🔧 chore(ci): build the sdist through PEP 517 (#453)
An sdist compiles nothing, so building it through maturin-action bought nothing beyond a bypass of the PEP 517 hooks that vendor toml-fmt-common. That bypass shipped a broken sdist in 2.29.1 and 1.10.1, and #452 answered it with a step running the backend CLI over the tarball afterwards. `uv build --sdist` reaches `build_sdist`, so the vendoring holds by construction instead of resting on a step someone has to remember to keep beside the build. ## Changes - The sdist job builds with `uv build --sdist`, and drops the backend CLI call and the tarball assertion that stood in for the hook. - The backend CLI patches wheels again, where cross-compilation leaves maturin-action no way through PEP 517. - `check_sdist.py` builds one sdist rather than two, since one path remains. The end-to-end check still proves the same thing: sdist, then a wheel built from it, then an empty environment with `--no-index` where the console script has to run on what the wheel alone carries.
1 parent 8b40ebe commit 7bd21dc

4 files changed

Lines changed: 18 additions & 43 deletions

File tree

‎.github/workflows/_build.yaml‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,14 @@ jobs:
215215
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
216216
with:
217217
name: source
218-
- name: 📦 Build sdist
219-
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1.51.0
220-
with:
221-
command: sdist
222-
args: -m ${{ inputs.package-name }}/Cargo.toml --out dist
223218
- name: 📦 Setup uv
224219
uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
225-
- name: 📦 Vendor toml-fmt-common into the sdist
226-
# maturin sdist (run by maturin-action) skips PEP 517, so vendor via the backend's CLI
227-
run: uv run --no-project "$PACKAGE/build_backend.py" dist
220+
- name: 📦 Build sdist
221+
# an sdist compiles nothing, so it goes through PEP 517 and the backend vendors toml-fmt-common
222+
run: uv build --sdist --out-dir dist "$PACKAGE"
228223
shell: bash
229224
env:
230225
PACKAGE: ${{ inputs.package-name }}
231-
- name: ✅ Check the sdist carries toml-fmt-common
232-
run: tar tzf dist/*.tar.gz | grep -q "toml-fmt-common/src/toml_fmt_common/__init__.py"
233-
shell: bash
234226
- name: 📤 Upload sdist
235227
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
236228
with:

‎pyproject-fmt/build_backend.py‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,12 @@ def main() -> None:
106106
if not common_is_present():
107107
print(f"no toml-fmt-common sources under {_COMMON}")
108108
raise SystemExit(1)
109-
built = sorted(target.glob("*.whl")) + sorted(target.glob("*.tar.gz")) if target.is_dir() else [target]
110-
if not built:
111-
print(f"no wheel or sdist found in {target}")
109+
if not (wheels := sorted(target.glob("*.whl")) if target.is_dir() else [target]):
110+
print(f"no wheels found in {target}")
112111
raise SystemExit(1)
113-
for path in built:
114-
if path.suffix == ".whl":
115-
vendor_into_wheel(path)
116-
else:
117-
vendor_into_sdist(path)
118-
print(f"vendored toml-fmt-common into {path.name}")
112+
for wheel in wheels:
113+
vendor_into_wheel(wheel)
114+
print(f"vendored toml-fmt-common into {wheel.name}")
119115

120116

121117
def vendor_into_wheel(wheel: Path) -> None:

‎tasks/check_sdist.py‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Build a package the way each release path builds it and run what comes out with no index behind it."""
1+
"""Build a package the way a release builds it and run what comes out with no index behind it."""
22

33
from __future__ import annotations
44

@@ -15,21 +15,12 @@
1515
def main(package: str) -> None:
1616
with TemporaryDirectory() as folder:
1717
at = Path(folder)
18-
released = maturin_sdist(package, at / "maturin")
19-
for sdist in (pep517_sdist(package, at / "pep517"), released):
20-
carries_common(sdist)
21-
runs_on_its_own(package, wheel_from(released, at / "wheel"), at / "venv")
18+
sdist = build_sdist(package, at / "sdist")
19+
carries_common(sdist)
20+
runs_on_its_own(package, wheel_from(sdist, at / "wheel"), at / "venv")
2221

2322

24-
def maturin_sdist(package: str, at: Path) -> Path:
25-
# a release builds the sdist through maturin-action, which never reaches the PEP 517 hooks
26-
manifest = _ROOT / package / "Cargo.toml"
27-
run("uv", "run", "--no-project", "--with", "maturin", "maturin", "sdist", "-m", str(manifest), "--out", str(at))
28-
run("uv", "run", "--no-project", str(_ROOT / package / "build_backend.py"), str(at))
29-
return next(at.glob("*.tar.gz"))
30-
31-
32-
def pep517_sdist(package: str, at: Path) -> Path:
23+
def build_sdist(package: str, at: Path) -> Path:
3324
run("uv", "build", "--sdist", "--out-dir", str(at), str(_ROOT / package))
3425
return next(at.glob("*.tar.gz"))
3526

‎tox-toml-fmt/build_backend.py‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,12 @@ def main() -> None:
106106
if not common_is_present():
107107
print(f"no toml-fmt-common sources under {_COMMON}")
108108
raise SystemExit(1)
109-
built = sorted(target.glob("*.whl")) + sorted(target.glob("*.tar.gz")) if target.is_dir() else [target]
110-
if not built:
111-
print(f"no wheel or sdist found in {target}")
109+
if not (wheels := sorted(target.glob("*.whl")) if target.is_dir() else [target]):
110+
print(f"no wheels found in {target}")
112111
raise SystemExit(1)
113-
for path in built:
114-
if path.suffix == ".whl":
115-
vendor_into_wheel(path)
116-
else:
117-
vendor_into_sdist(path)
118-
print(f"vendored toml-fmt-common into {path.name}")
112+
for wheel in wheels:
113+
vendor_into_wheel(wheel)
114+
print(f"vendored toml-fmt-common into {wheel.name}")
119115

120116

121117
def vendor_into_wheel(wheel: Path) -> None:

0 commit comments

Comments
 (0)