You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there! I noticed that when doing maturin build --sdist on a git managed repo with data files, the files included in the wheel were omitted in the sdist. After investigating further, I realized the pattern matching behavior for the entries in tool.maturin.include differs for sdist and wheel targets. Let me try to explain:
Note that bar.html is already committed to the repo. Now if I do maturin build --sdist, the resulting tarball does not contain bar.html but the wheel has it. To include it in both, one can do either:
By adding sdist-generator = "git" under tool.maturin, or
By modifying include to have separate entries for wheel and sdist
include = [{ path = "src/python/pyfoo/bar.html", format = "sdist"}, {path = "pyfoo/bar.html", format="wheel"}]
or
3. By having an extra bit of globbing in the path, e.g. include = ["**/pyfoo/bar.html"].
Option 1 only works if bar.html is committed to the repo. Option 2 creates unnecessary duplication. Option 3 is fine as a workaround but I would expect the behavior without double wildcard to be the same.
Your maturin version (maturin --version)
1.7.4
Your Python version (python -V)
3.9.20
Your pip version (pip -V)
uv-pip 0.4.20
What bindings you're using
pyo3
Does cargo build work?
Yes, it works
If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?
Yes
Steps to Reproduce
mkdir foobar && cd foobar
Cargo.toml
[workspace.package]
version = "0.1.0"authors = ["footang"]
edition = "2021"publish = false
[workspace]
members = ["**/src/rust/*"]
resolver = "2"
[package]
name = "rustfoo"version.workspace = trueauthors.workspace = trueedition.workspace = truepublish.workspace = true
[lib]
name = "rustfoo"crate-type = ["cdylib"]
[dependencies.pyo3]
version = "0.22.2"
[features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]
src/rust/rustfoo/src/lib.rs
use pyo3::prelude::*;/// Formats the sum of two numbers as string.#[pyfunction]fnsum_as_string(a:usize,b:usize) -> PyResult<String>{Ok((a + b).to_string())}/// A Python module implemented in Rust.#[pymodule]fnrustfoo(m:&Bound<'_,PyModule>) -> PyResult<()>{
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;Ok(())}
Run maturin build --sdist and observe the built sdist under target/wheels/foo-0.1.0.tar.gz does not contain bar.html. (I used maturin build --sdist --zig && tar xzf target/wheels/pyfoo-0.1.0.tar.gz && ls -ahl pyfoo-0.1.0/src/python/pyfoo && rm -rf target && rm -rf pyfoo-0.1.0 to quickly iterate on changes)
The text was updated successfully, but these errors were encountered:
ckutlu
changed the title
Include pattern behaves differently when building sdist versus wheel
Include pattern treated differently when building sdist versus wheel
Nov 26, 2024
Bug Description
Hi there! I noticed that when doing
maturin build --sdist
on a git managed repo with data files, the files included in the wheel were omitted in the sdist. After investigating further, I realized the pattern matching behavior for the entries intool.maturin.include
differs for sdist and wheel targets. Let me try to explain:The folder structure is:
pyproject.toml
containsand .gitignore contains
Note that
bar.html
is already committed to the repo. Now if I domaturin build --sdist
, the resulting tarball does not contain bar.html but the wheel has it. To include it in both, one can do either:sdist-generator = "git"
under tool.maturin, oror
3. By having an extra bit of globbing in the path, e.g.
include = ["**/pyfoo/bar.html"]
.Option 1 only works if
bar.html
is committed to the repo. Option 2 creates unnecessary duplication. Option 3 is fine as a workaround but I would expect the behavior without double wildcard to be the same.Your maturin version (
maturin --version
)1.7.4
Your Python version (
python -V
)3.9.20
Your pip version (
pip -V
)uv-pip 0.4.20
What bindings you're using
pyo3
Does
cargo build
work?If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash
/
)?Steps to Reproduce
mkdir foobar && cd foobar
touch src/python/pyfoo/bar.html
git init && git add . && git commit -m "mre"
.gitignore
maturin build --sdist
and observe the built sdist undertarget/wheels/foo-0.1.0.tar.gz
does not containbar.html
. (I usedmaturin build --sdist --zig && tar xzf target/wheels/pyfoo-0.1.0.tar.gz && ls -ahl pyfoo-0.1.0/src/python/pyfoo && rm -rf target && rm -rf pyfoo-0.1.0
to quickly iterate on changes)The text was updated successfully, but these errors were encountered: