maturin icon indicating copy to clipboard operation
maturin copied to clipboard

Maturin fails to use workspace license file

Open anuradhawick opened this issue 5 months ago • 4 comments

Bug Description

I have a workspace with multiple rust crates. The following fails

[package]
name = "pip"
version.workspace = true
edition.workspace = true
authors.workspace = true
description.workspace = true
readme.workspace = true
license-file.workspace = true

with error

💥 maturin failed
  Caused by: license file `/home/anuvini/Desktop/kmertools/LICENSE` exists outside of the project root `/home/anuvini/Desktop/kmertools/pip`
  Caused by: prefix not found

If I remove license-file.workspace = true and add a symlink to license in root folder, it succeeds.

Only started seeing this issue since I updated from 1.7.8 to 1.9.4

Your maturin version (maturin --version)

1.9.4

Your Python version (python -V)

3.10.9

Your pip version (pip -V)

pip 23.0

What bindings you're using

pyo3

Does cargo build work?

  • [x] 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

Create a rust workspace

Add a crate that uses maturin

Add license path as follows in the Cargo.toml

license-file.workspace = true

anuradhawick avatar Sep 19 '25 03:09 anuradhawick

We are seeing the same issue, it is quite problematic because it requires either to:

  • Duplicate the license file (which is horrible design)
  • Create a symlinks (which can't be trusted, they are often a source of bug and else)

Is this a voluntary design or a bug?

Most maturin projects are mono repos with multiple crates/packages in it (that's the nature of the systems build with it), it would be really nice if maturin could take this into account and enable license file in parent folders

vemonet avatar Nov 11 '25 09:11 vemonet

Exactly my problem. Project contains multiple crates and I intend to share the license.

Using symlink is more of a hack when the option to use workspace license is clearly there.

Seems to me like a bug.

anuradhawick avatar Nov 11 '25 09:11 anuradhawick

Cool, now cargo deny fails due to the symbolic link (as expected.)

error[unlicensed]: nanopub-sign = 0.1.4 is unlicensed
  ┌─ path+file:///Users/vemonet/dev/nanopub/nanopub-rs/python#[email protected]:2:9
  │
2 │ name = "nanopub-sign"
  │         ━━━━━━━━━━━━ a valid license expression could not be retrieved for the crate
3 │ version = "0.1.4"
4 │ license = ""
  │            ─ license expression was not specified
5 │ license-files = [
6 │     { path = "/Users/vemonet/dev/nanopub/nanopub-rs/python/LICENSE.txt", err = "Too many levels of symbolic links (os error 62)" },
  │                                                                                 ─────────────────────────────────────────────── unable to read license file
  │
  ├ nanopub-sign v0.1.4

licenses FAILED

So the only solution is duplicating the license file...

vemonet avatar Nov 11 '25 09:11 vemonet

Same issue here, reverted back to 1.8

krokosik avatar Nov 12 '25 16:11 krokosik