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.91k stars 271 forks source link

Panic running sdist when `python-source` points outside of Rust source directory #2202

Open ia0 opened 2 months ago

ia0 commented 2 months ago

Bug Description

maturin has panicked. This is a bug in maturin. Please report this
at https://github.com/PyO3/maturin/issues/new/choose.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 environment
variable set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.7.1
Args: maturin sdist

thread 'main' panicked at /usr/local/google/home/cretin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/maturin-1.7.1/src/source_distribution.rs:617:75:
called `Result::unwrap()` on an `Err` value: StripPrefixError(())

Note that I'm most probably doing something wrong (I'm trying to build some wheels with a Python library and a Rust binary). But given it's a panic and apparently panics are not expected in Maturin, I'm creating a bug report.

Your maturin version (maturin --version)

1.7.1

Your Python version (python -V)

I don't have python, but python3 -V gives 3.11.9

Your pip version (pip -V)

24.0

What bindings you're using

bin

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

cd /tmp
git clone -b release git@github.com:ia0/magika.git
cd magika/rust/cli
maturin sdist

The current commit hash of the branch on my fork is 635af61bfcbc87df2b6e6ee982c701155fad6bde in case this changes before anyone tries to reproduce.

messense commented 2 months ago

My guess is that the problem is caused by the pyproject.toml symlink, maturin has canonicalized it.

Will take a further look later.

messense commented 2 months ago

I took a look today, the problem is actually python-source = "../../python" option, we don't actually support python-source outside of rust source directory yet, it must be inside or sibling of the rust source directory.