Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace inherited dev dependencies are not rewritten in sdist #1609

Closed
2 tasks done
konstin opened this issue May 15, 2023 · 0 comments · Fixed by #1610
Closed
2 tasks done

Workspace inherited dev dependencies are not rewritten in sdist #1609

konstin opened this issue May 15, 2023 · 0 comments · Fixed by #1610
Labels
bug Something isn't working

Comments

@konstin
Copy link
Member

konstin commented May 15, 2023

Bug Description

Workspace inherited dev dependencies are not rewritten when creating source distributions.

In ruff, we have a workspace with a crates folder that contains a ruff and a ruff-cli crate, where the latter is the main entrypoint.

In the main pyproject.toml:

[tool.maturin]
bindings = "bin"
manifest-path = "crates/ruff_cli/Cargo.toml"
module-name = "ruff"
python-source = "python"

In the main Cargo.toml, we define all the versions, including e.g. colored:

[workspace.dependencies]
anyhow = { version = "1.0.69" }
bitflags = { version = "2.2.1" }
chrono = { version = "0.4.23", default-features = false, features = ["clock"] }
clap = { version = "4.1.8", features = ["derive"] }
colored = { version = "2.0.0" }

In crates/ruff/Cargo.toml, we have dev dependencies using them:

[dev-dependencies]
insta = { workspace = true }
pretty_assertions = "1.3.0"
test-case = { workspace = true }
# Disable colored output in tests
colored = { workspace = true, features = ["no-color"] }

When you build a source distribution, these don't get rewritten, but the workspace is gone, so pip install ruff-0.0.267.tar.gz fails to resolve the colored = { workspace = true, features = ["no-color"] } in local_dependencies/ruff/Cargo.toml in the source distribution:

Processing ./ruff-0.0.267.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      error: failed to get `ruff` as a dependency of package `ruff_cli v0.0.267 (/tmp/pip-req-build-p8mkavn0/crates/ruff_cli)`
      
      Caused by:
        failed to load source for dependency `ruff`
      
      Caused by:
        Unable to update /tmp/pip-req-build-p8mkavn0/local_dependencies/ruff
      
      Caused by:
        failed to parse manifest at `/tmp/pip-req-build-p8mkavn0/local_dependencies/ruff/Cargo.toml`
      
      Caused by:
        error inheriting `colored` from workspace root manifest's `workspace.dependencies.colored`
      
      Caused by:
        failed to find a workspace root
      💥 maturin failed
        Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
        Caused by: `cargo metadata` exited with an error:
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/tmp/pip-modern-metadata-_g8webjv', '--interpreter', '/home/konsti/sdist-ruff/.venv/bin/python']' returned non-zero exit status 1.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory /tmp/pip-modern-metadata-_g8webjv --interpreter /home/konsti/sdist-ruff/.venv/bin/python`
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Your maturin version (maturin --version)

v0.15.1-16-g9fbf8fa (9fbf8fa)

Your Python version (python -V)

n/a (Python 3.11.2)

Your pip version (pip -V)

n/a (pip 23.0.1)

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

git clone https://github.com/charliermarsh/ruff
cd ruff
maturin sdist
pip install ruff-0.0.267.tar.gz
$ RUST_LOG=maturin=debug ~/maturin/target/debug/maturin sdist
2023-05-15T12:42:36.057897Z DEBUG maturin::project_layout: Found pyproject.toml in working directory at "/home/konsti/ruff/pyproject.toml"
2023-05-15T12:42:36.062697Z DEBUG maturin::project_layout: Using cargo manifest path from pyproject.toml "crates/ruff_cli/Cargo.toml"
2023-05-15T12:42:36.066487Z DEBUG maturin::project_layout: Resolving cargo metadata from "/home/konsti/ruff/crates/ruff_cli/Cargo.toml"
2023-05-15T12:42:36.322613Z DEBUG maturin::project_layout: Project layout resolved project_root=/home/konsti/ruff python_dir=/home/konsti/ruff/python rust_module=/home/konsti/ruff/python/ruff python_module=/home/konsti/ruff/python/ruff extension_name=ruff module_name=ruff
🍹 Building a mixed python/rust project
🔗 Found bin bindings
📡 Using build options bindings from pyproject.toml
2023-05-15T12:42:36.379765Z DEBUG maturin::source_distribution: Skipping development only dependency ruff_macros (/home/konsti/ruff/crates/ruff_macros)
2023-05-15T12:42:36.380444Z DEBUG maturin::source_distribution: Skipping development only dependency ruff_macros (/home/konsti/ruff/crates/ruff_macros)
2023-05-15T12:42:36.550363Z DEBUG maturin::module_writer: Adding ruff-0.0.267/local_dependencies/ruff_diagnostics/Cargo.toml
2023-05-15T12:42:36.550575Z DEBUG maturin::module_writer: Adding ruff-0.0.267/local_dependencies/ruff_diagnostics/src/diagnostic.rs from /home/konsti/ruff/crates/ruff_diagnostics/src/diagnostic.rs
2023-05-15T12:42:36.550707Z DEBUG maturin::module_writer: Adding ruff-0.0.267/local_dependencies/ruff_diagnostics/src/edit.rs from /home/konsti/ruff/crates/ruff_diagnostics/src/edit.rs
2023-05-15T12:42:36.550845Z DEBUG maturin::module_writer: Adding ruff-0.0.267/local_dependencies/ruff_diagnostics/src/fix.rs from /home/konsti/ruff/crates/ruff_diagnostics/src/fix.rs
2023-05-15T12:42:36.550983Z DEBUG maturin::module_writer: Adding ruff-0.0.267/local_dependencies/ruff_diagnostics/src/lib.rs from /home/konsti/ruff/crates/ruff_diagnostics/src/lib.rs
2023-05-15T12:42:36.551057Z DEBUG maturin::module_writer: Adding ruff-0.0.267/local_dependencies/ruff_diagnostics/src/violation.rs from /home/konsti/ruff/crates/ruff_diagnostics/src/violation.rs
2023-05-15T12:42:36.721436Z DEBUG maturin::module_writer: Adding ruff-0.0.267/local_dependencies/ruff_python_stdlib/Cargo.toml

[... lots and lots of paths ...]

2023-05-15T12:42:38.236751Z DEBUG maturin::module_writer: Adding ruff-0.0.267/crates/ruff_cli/tests/integration_test.rs from /home/konsti/ruff/crates/ruff_cli/tests/integration_test.rs
2023-05-15T12:42:38.236924Z DEBUG maturin::module_writer: Adding ruff-0.0.267/pyproject.toml from /home/konsti/ruff/pyproject.toml
2023-05-15T12:42:38.237087Z DEBUG maturin::module_writer: Adding ruff-0.0.267/crates/ruff_cli/Cargo.lock from /home/konsti/ruff/Cargo.lock
2023-05-15T12:42:38.244096Z DEBUG maturin::module_writer: Adding ruff-0.0.267/python/ruff/__main__.py from /home/konsti/ruff/python/ruff/__main__.py
2023-05-15T12:42:38.244266Z DEBUG maturin::module_writer: Adding ruff-0.0.267/python/ruff/__init__.py from /home/konsti/ruff/python/ruff/__init__.py
2023-05-15T12:42:38.244426Z DEBUG maturin::module_writer: Adding ruff-0.0.267/README.md from /home/konsti/ruff/README.md
2023-05-15T12:42:38.245267Z DEBUG maturin::module_writer: Adding ruff-0.0.267/LICENSE from /home/konsti/ruff/LICENSE
2023-05-15T12:42:38.246736Z DEBUG maturin::module_writer: Adding ruff-0.0.267/PKG-INFO
📦 Built source distribution to /home/konsti/ruff/target/wheels/ruff-0.0.267.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant