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

pip can't build wheel from sdist when explicitly listing workspaces #838

Closed
2 tasks done
anthrotype opened this issue Mar 10, 2022 · 2 comments · Fixed by #844
Closed
2 tasks done

pip can't build wheel from sdist when explicitly listing workspaces #838

anthrotype opened this issue Mar 10, 2022 · 2 comments · Fixed by #844
Labels
bug Something isn't working

Comments

@anthrotype
Copy link

anthrotype commented Mar 10, 2022

Bug Description

I'm trying to package up a bin crate where the top-level Cargo.toml declares a workspace with explicit members (as relative subfolders) then each members' Cargo.toml contain explicit backreferences to the root workspace directory via package.worskspace containing "..".
maturin is able to build a wheel and does not return any error while building the sdist package either. However, if I try to run pip wheel or pip install using the source distribution tar.gz file that maturin build (like pip would do when a binary wheel is not found, it falls back to building from source), then cargo fails with errors that it can't load the manifest for the workspace members.

This is because maturin moves the workpace members to a local_dependencies subdirectory, without also updating the workspace relative paths in the root's and the members' Cargo.toml.

In theory these explicit workspace subfolders listings and backrefs can be omitted because cargo can figure them out automatically. In fact that's what I am currently doing, I have a python script that loads the Cargo.toml files and remove the "members" key from the root workspace as well as the "package.workspace" key from the members' manifest, just before calling maturin sdist.
Pip wheel then works fine because there are no more hard-coded relative paths to the workspace.

However, I can't/don't want to modify the upstream project's cargo setup, because I don't control this and I just want to build a python sdist/wheel for it.

Please find below the command to reproduce this.
Thank you for considering.

Your Python version (python -V)

Python 3.10.2

Your pip version (pip -V)

22.0.4

What bindings you're using

bin

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 --branch maturin https://github.com/anthrotype/resvg
$ cd resvg
$ maturin sdist -o dist
$ pip wheel dist/resvg_cli-*.tar.gz
Processing ./target/wheels/resvg_cli-0.22.1b1.tar.gz
  File was already downloaded /Users/clupo/Github/resvg-wheels/resvg/target/wheels/resvg_cli-0.22.1b1.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
  ╰─> [12 lines of output]
      💥 maturin failed
        Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
        Caused by: `cargo metadata` exited with an error: error: failed to load manifest for workspace member `/private/var/folders/fd/t86sf39s0_b_vn713l6w1ztc00g3y4/T/pip-req-build-itft32_d/c-api`

      Caused by:
        failed to read `/private/var/folders/fd/t86sf39s0_b_vn713l6w1ztc00g3y4/T/pip-req-build-itft32_d/c-api/Cargo.toml`

      Caused by:
        No such file or directory (os error 2)
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/private/var/folders/fd/t86sf39s0_b_vn713l6w1ztc00g3y4/T/pip-modern-metadata-8ho1nilj', '--interpreter', '/Users/clupo/Github/resvg-wheels/.venv/bin/python3.10']' returned non-zero exit status 1.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory /private/var/folders/fd/t86sf39s0_b_vn713l6w1ztc00g3y4/T/pip-modern-metadata-8ho1nilj --interpreter /Users/clupo/Github/resvg-wheels/.venv/bin/python3.10`
      [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.
@messense
Copy link
Member

@anthrotype Can you try #844 ?

@messense
Copy link
Member

#844 released in v0.12.11.

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.

2 participants