PyO3 / maturin

Build and publish crates with pyo3, cffi and uniffi bindings as well as rust binaries as python packages
https://maturin.rs
Apache License 2.0
3.99k stars 275 forks source link

`maturin build --sdist`: README.md was already added for workspace crate #2244

Closed mhils closed 1 month ago

mhils commented 1 month ago

Bug Description

With a README file both in the workspace root and the crate root:

building a source distribution fails:

$ cd mitmproxy-rs
$ RUST_LOG=maturin=debug maturin build --sdist
2024-10-02T14:12:48.035925Z DEBUG into_build_context: maturin::project_layout: Found pyproject.toml in working directory at "/Users/mhils/git/mitmproxy_rs/mitmproxy-rs/pyproject.toml"
2024-10-02T14:12:48.037519Z DEBUG into_build_context: maturin::project_layout: Using cargo manifest path from working directory: "/Users/mhils/git/mitmproxy_rs/mitmproxy-rs/Cargo.toml"
2024-10-02T14:12:48.037891Z DEBUG into_build_context:resolve_cargo_metadata: maturin::project_layout: Resolving cargo metadata from "/Users/mhils/git/mitmproxy_rs/mitmproxy-rs/Cargo.toml"
2024-10-02T14:12:48.247759Z  INFO into_build_context:resolve_cargo_metadata: maturin::project_layout: close time.busy=210ms time.idle=1.25ยตs
2024-10-02T14:12:48.248315Z DEBUG into_build_context: maturin::project_layout: Project layout resolved project_root=/Users/mhils/git/mitmproxy_rs/mitmproxy-rs python_dir=/Users/mhils/git/mitmproxy_rs/mitmproxy-rs rust_module=/Users/mhils/git/mitmproxy_rs/mitmproxy-rs/mitmproxy_rs python_module=/Users/mhils/git/mitmproxy_rs/mitmproxy-rs/mitmproxy_rs extension_name=mitmproxy_rs module_name=mitmproxy_rs
๐Ÿน Building a mixed python/rust project
๐Ÿ”— Found pyo3 bindings with abi3 support for Python โ‰ฅ 3.10
2024-10-02T14:12:48.340243Z DEBUG into_build_context:check_executable: maturin::python_interpreter: Found CPython interpreter at /Users/mhils/git/mitmproxy/venv/bin/python executable=python
2024-10-02T14:12:48.340263Z  INFO into_build_context:check_executable: maturin::python_interpreter: close time.busy=49.0ms time.idle=1.83ยตs executable=python
๐Ÿ Not using a specific python interpreter
๐Ÿ“ก Using build options features from pyproject.toml
2024-10-02T14:12:48.340320Z  INFO into_build_context: maturin::build_options: close time.busy=305ms time.idle=1.50ยตs
2024-10-02T14:12:48.388449Z DEBUG maturin::source_distribution: Found path dependencies: ["mitmproxy"]
2024-10-02T14:12:48.388466Z DEBUG maturin::source_distribution: Found sdist root: /Users/mhils/git/mitmproxy_rs
2024-10-02T14:12:48.388469Z DEBUG maturin::source_distribution: Adding path dependency: mitmproxy at /Users/mhils/git/mitmproxy_rs/Cargo.toml
[...]
2024-10-02T14:12:48.503569Z DEBUG maturin::module_writer: Adding mitmproxy_rs-0.10.1.dev0/LICENSE from /Users/mhils/git/mitmproxy_rs/LICENSE
2024-10-02T14:12:48.503663Z DEBUG maturin::module_writer: Adding mitmproxy_rs-0.10.1.dev0/README.md from /Users/mhils/git/mitmproxy_rs/README.md
[...]
2024-10-02T14:12:48.664433Z DEBUG maturin::source_distribution: Rewriting Cargo.toml `package.readme` at /Users/mhils/git/mitmproxy_rs/mitmproxy-rs/Cargo.toml
2024-10-02T14:12:48.664452Z DEBUG maturin::source_distribution: Rewriting Cargo.toml `workspace.members` at /Users/mhils/git/mitmproxy_rs/mitmproxy-rs/Cargo.toml
[...]
2024-10-02T14:12:48.664641Z DEBUG maturin::module_writer: Adding mitmproxy_rs-0.10.1.dev0/mitmproxy-rs/README.md from /Users/mhils/git/mitmproxy_rs/mitmproxy-rs/README.md
[...]
2024-10-02T14:12:48.667225Z DEBUG maturin::module_writer: Adding mitmproxy_rs-0.10.1.dev0/mitmproxy-rs/stubtest-allowlist.txt from /Users/mhils/git/mitmproxy_rs/mitmproxy-rs/stubtest-allowlist.txt
๐Ÿ’ฅ maturin failed
  Caused by: Failed to build source distribution
  Caused by: File mitmproxy_rs-0.10.1.dev0/README.md was already added from /Users/mhils/git/mitmproxy_rs/README.md, can't added it from /Users/mhils/git/mitmproxy_rs/mitmproxy-rs/README.md

Cargo.toml, mitmproxy-rs/Cargo.toml, and mitmproxy-rs/pyproject.toml do not specify any (custom) settings w.r.t. READMEs. I would have expected maturin to use mitmproxy-rs/README.md and not README.md.

This is a regression that started in 1.7.1. Refs https://github.com/PyO3/maturin/pull/2184 and https://github.com/PyO3/maturin/issues/2154.

Your maturin version (maturin --version)

1.7.4

Your Python version (python -V)

3.12

Your pip version (pip -V)

all

What bindings you're using

pyo3

Does cargo build work?

deadsoul44 commented 1 month ago

What is ETA for this? (no pressure intended)

mhils commented 1 month ago

Thank you, @konstin! ๐Ÿ˜ƒ ๐Ÿฐ

AnBowell commented 3 days ago

I managed to run into this issue running on the bug-fixed v1.7.5

Found maturin version requirement maturin>=1.0,<2.0 specified in pyproject.toml
Found maturin release from manifest: v1.7.5

...

๐Ÿ’ฅ maturin failed
  Caused by: Failed to build source distribution
  Caused by: File whittaker_eilers-0.2.0/README.md was already added from /home/runner/work/whittaker-eilers/whittaker-eilers/README.md, can't added it from /home/runner/work/whittaker-eilers/whittaker-eilers/whittaker-eilers-py/README.md

I reverted back to v1.6.0 and it was working once again.

I did double check and this issue was fixed in #2262 and mentioned in the v1.7.5 release but it seems like the issue is still present.

kemingy commented 2 days ago

I also encounter this issue with version v1.7.5 if I have

[project]
readme = "README.md"

in the pyproject.toml.