Skip to content

Fix Python release: sdist build failure and restore tag trigger - #314

Open
TomBener wants to merge 1 commit into
huacnlee:mainfrom
TomBener:fix/python-release-sdist
Open

Fix Python release: sdist build failure and restore tag trigger#314
TomBener wants to merge 1 commit into
huacnlee:mainfrom
TomBener:fix/python-release-sdist

Conversation

@TomBener

Copy link
Copy Markdown
Contributor

Problem

autocorrect-py on PyPI is stuck at 2.14.0 (2025-04-26), while this repo is at v2.16.3. Versions 2.14.1 through 2.16.3 were never published.

Two things went wrong, one after the other:

1. The macos job started failing at v2.14.1.

It is the only job that passes --sdist, and since publish declares needs: [macos, ...], that one failure skipped the upload entirely — the other 13 build jobs were all green, but nothing reached PyPI. This happened for both v2.14.1 and v2.14.2 (the job died after ~40s; the logs have since expired).

The cause is a file collision when maturin packs the autocorrect path dependency into the sdist:

💥 maturin failed
  Caused by: Failed to build source distribution
  Caused by: Failed to add path dependency autocorrect
  Caused by: File autocorrect_py-2.16.3/autocorrect/README.md was already added
             from autocorrect/README.md, can't add it from README.md

autocorrect/Cargo.toml declares readme = "../README.md", but autocorrect/README.md also exists, so both files end up at the same path inside the sdist. Cargo already warns about this today and silently packs the in-package copy:

warning: readme `../README.md` appears to be a path outside of the package, but there is
already a file named `README.md` in the root of the package. The archived crate will
contain the copy in the root of the package.

This surfaced at v2.14.1 because #267 moved autocorrect-py/pyproject.toml from maturin>=0.13,<0.14 to maturin>=1.9.0,<2.0.0. maturin 0.13 did not pack path dependencies this way; every maturin from 1.8.7 through 1.11.5 hits the collision. I verified this locally version by version — 1.8.7 / 1.9.0 / 1.9.1 / 1.9.6 / 1.10.2 / 1.11.5 all fail, 1.12.6 / 1.13.3 / 1.14.1 succeed (maturin fixed it in 1.12.0, released 2026-02-14).

2. The tag trigger was then removed.

9a81398 ("ci: Disable auto release rust, ruby, java, python.") switched release-py.yml to workflow_dispatch only. It has not run since 2025-07-25, so tagging a release no longer builds or publishes the Python package at all.

Solution

Two lines:

  • autocorrect/Cargo.toml: point readme at the in-package README.md. This is the file Cargo already ships, so nothing changes on crates.io — it just makes the manifest match reality and removes the collision. This fixes the sdist build on every maturin version, so no version pin is needed.
  • .github/workflows/release-py.yml: restore the push: tags: v* trigger alongside workflow_dispatch.

Testing

Local, against the maturin version that was actually in use when CI broke (1.9.1):

$ maturin build --release --out dist --sdist -m autocorrect-py/Cargo.toml
📦 Built source distribution to dist/autocorrect_py-2.16.3.tar.gz
📦 Built wheel for abi3 Python ≥ 3.7 to dist/autocorrect_py-2.16.3-cp37-abi3-macosx_11_0_arm64.whl

$ pip install --no-binary :all: dist/autocorrect_py-2.16.3.tar.gz
Successfully installed autocorrect-py-2.16.3
$ python -c "import autocorrect_py as ac; print(ac.format('你好hello世界123'))"
你好 hello 世界 123

The x86_64-apple-darwin cross build also succeeds.

Full workflow run on my fork: https://github.com/TomBener/autocorrect/actions/runs/29832606315

All 13 build jobs pass, including macos, and its artifact now contains what was missing:

autocorrect_py-2.16.3-cp37-abi3-macosx_10_12_x86_64.whl
autocorrect_py-2.16.3-cp37-abi3-macosx_11_0_arm64.whl
autocorrect_py-2.16.3.tar.gz

As in #227, the only expected failure is publish, which gets a 403 from PyPI because a fork has no credentials.

I did not touch release-java.yml or release-crate-gem.yml, which were disabled in the same commit — crates.io is also still at 2.14.2, but that is a separate call for you to make.

The `macos` job is the only one passing `--sdist`, and it has failed since
v2.14.1 because maturin cannot pack the `autocorrect` path dependency:

    Caused by: Failed to add path dependency autocorrect
    Caused by: File autocorrect_py-x.y.z/autocorrect/README.md was already
               added from autocorrect/README.md, can't add it from README.md

`autocorrect/Cargo.toml` declares `readme = "../README.md"` while
`autocorrect/README.md` also exists, so both files end up at the same path
inside the sdist. Cargo already warns about this and silently packs the
in-package copy, so pointing `readme` at it changes nothing on crates.io.

Since `publish` needs the `macos` job, a single failure there skipped the
upload entirely and no wheels reached PyPI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants