Skip to content

sdist: include the crate's tests/*.rs, which Cargo.toml can name (needed by #305) - #309

Open
bee-san wants to merge 1 commit into
mainfrom
pywhat-rs-py-sdist
Open

bee-san wants to merge 1 commit into
mainfrom
pywhat-rs-py-sdist

Conversation

@bee-san

@bee-san bee-san commented Nov 5, 2026

Copy link
Copy Markdown
Owner

A one-line packaging fix that #305 (the Rust CLI) needs before it can land.

The problem

maturin sdist copies the workspace's Cargo.toml as it is, and takes the crate's files from cargo package, which leaves out everything outside the crate's include (src/, the data, LICENSE, NOTICE, README.md). #304 already added benches/ and examples/ to the sdist for that reason: Cargo.toml names [[bench]] and [[example]] targets, and cargo refuses to read a manifest whose explicit targets have no file.

#305 adds an explicit [[test]] name = "cli" (required-features = ["cli"]). Without tests/cli.rs in the sdist, pip install from the sdist fails. I checked this on #305's branch as pywhat-rs-cli has rebased it onto main 0c78b02 (their commits f1bc150, 896c2fe and 5f38d67, not pushed yet):

$ maturin sdist --out sd && pip install sd/pywhat-6.0.0a1.tar.gz
      error: Cargo.toml: can't find `cli` test at `tests/cli.rs` or `tests/cli/main.rs`. Please specify test.path if you want to use a non-default path.
      error: could not parse `pywhat` (manifest) due to 1 previous error

Once #305 is rebased, the Release workflow will run on it (it changes Cargo.toml), and its sdist job (Try the sdist) will fail the same way.

The fix

pyproject.toml: { path = "tests/**/*.rs", format = "sdist" } next to the benches and examples. The sdist only builds the library, so the tests' contents don't matter; they make the manifest readable. The .crate that cargo package builds doesn't change.

Commands and results

  • On main 0c78b02 with this change: maturin sdist (maturin 1.16.0) gives an sdist with tests/charset_only.rs, tests/cli.rs, tests/examples.rs, tests/golden.rs, tests/whole.rs (and LICENSE, NOTICE, the benches and the example). pip install of it into a fresh Python 3.12 venv works: pywhat --version prints PyWhat version 6.0.0a1, and pywhat._pywhat has MatchError, Text and finditer.
  • On Rust port phase 4: the what/pywhat CLI in Rust, byte for byte like pyWhat's (#291) #305's rebased tree (5f38d67) with this pyproject.toml: the same, and pip install from the sdist works (rc 0). Without it: the error above.
  • Local CI (/local/home/skerraut/herd-synth3/reports/pywhat-rs-py-evidence/local_ci.sh under gate.sh) on this head: cargo fmt, clippy (3 runs, with -p pywhat-py), cargo test (3 runs) pass; nox -s tests on Python 3.8: 2424 passed, 6 skipped; on 3.12: 2427 passed, 3 skipped; the wheel (1,676,699 bytes) installs on 3.8 and 3.12, the sdist (719,102 bytes) on 3.12, and the smoke test finds ['LICENSE', 'NOTICE'] in both.
  • The wheel's file list (43 files) and cargo package --list -p pywhat (39 files) are the same on main and on this head.
  • CI: pending (the Release workflow runs, as pyproject.toml changes).

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

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.

1 participant