Skip to content

Don't package non-path-dep crates in sdist for workspaces - #720

Merged
messense merged 3 commits into
PyO3:mainfrom
messense:workspace-path-dep
Dec 1, 2021
Merged

Don't package non-path-dep crates in sdist for workspaces#720
messense merged 3 commits into
PyO3:mainfrom
messense:workspace-path-dep

Conversation

@messense

@messense messense commented Dec 1, 2021

Copy link
Copy Markdown
Member

Fixes #462

For the included workspace setup, before:

❯ tar -ztf dist/workspace_with_path_dep-0.1.0.tar.gz
workspace_with_path_dep-0.1.0/local_dependencies/generic_lib/Cargo.toml
workspace_with_path_dep-0.1.0/local_dependencies/generic_lib/src/lib.rs
workspace_with_path_dep-0.1.0/local_dependencies/dont_include_in_sdist/Cargo.toml
workspace_with_path_dep-0.1.0/local_dependencies/dont_include_in_sdist/src/main.rs
workspace_with_path_dep-0.1.0/Cargo.toml
workspace_with_path_dep-0.1.0/pyproject.toml
workspace_with_path_dep-0.1.0/src/lib.rs
workspace_with_path_dep-0.1.0/PKG-INFO

after:

❯ tar -ztf dist/workspace_with_path_dep-0.1.0.tar.gz
workspace_with_path_dep-0.1.0/local_dependencies/generic_lib/Cargo.toml
workspace_with_path_dep-0.1.0/local_dependencies/generic_lib/src/lib.rs
workspace_with_path_dep-0.1.0/Cargo.toml
workspace_with_path_dep-0.1.0/pyproject.toml
workspace_with_path_dep-0.1.0/src/lib.rs
workspace_with_path_dep-0.1.0/PKG-INFO

TODO:

  • Fix transitive path dependency.

@netlify

netlify Bot commented Dec 1, 2021

Copy link
Copy Markdown

✔️ Deploy Preview for maturin-guide canceled.

🔨 Explore the source changes: b7f18b4

🔍 Inspect the deploy log: https://app.netlify.com/sites/maturin-guide/deploys/61a77bce2781ff000741a31a

@messense
messense force-pushed the workspace-path-dep branch 2 times, most recently from e60ed9e to 089b79d Compare December 1, 2021 05:33
@messense
messense marked this pull request as draft December 1, 2021 05:38
@messense
messense marked this pull request as ready for review December 1, 2021 07:11
@messense
messense requested a review from konstin December 1, 2021 07:13
@messense
messense force-pushed the workspace-path-dep branch 3 times, most recently from 5184099 to fb9825c Compare December 1, 2021 07:22
@messense
messense requested a review from davidhewitt December 1, 2021 07:22
@messense

messense commented Dec 1, 2021

Copy link
Copy Markdown
Member Author

This one is a little tricky, I'd love to have more eyes on it.

cc @koehlma

@davidhewitt

Copy link
Copy Markdown
Member

👍 happy to review however I don't think I'll manage to get to this before the weekend FYI. My FIFO queue is backed up a bit this week 😅

@koehlma

koehlma commented Dec 1, 2021

Copy link
Copy Markdown
Contributor

Hey, thanks for addressing this.

It seems to me that this approach misses transitive path dependencies. Imagine I have the dependency graph A → B → C and these are all path dependencies. Now, A.deps does contain B but not C because the dependency graph provided by cargo_metadata is transitivity reduced as far as I know. So, after discovering that B is a dependency of A the dependencies of B should be scanned and so on. If I may, I would also suggest factoring out the scanning for path dependencies into its own function.

I once implemented this as follows: https://github.com/koehlma/maturin/blob/master/src/source_distribution.rs#L146 This solution also does not depend on the repr of a package identifier.

@messense

messense commented Dec 1, 2021

Copy link
Copy Markdown
Member Author

@koehlma Thanks for the review!

I'm a little worried that this top.dependencies
https://github.com/koehlma/maturin/blob/dee86e60b1771055210d04fff5d8509d80a0fe04/src/source_distribution.rs#L155 doesn’t support renamed dependencies. Not sure if it breaks anything, needs to give it a test.

image

@koehlma

koehlma commented Dec 1, 2021

Copy link
Copy Markdown
Contributor

@messense My pleasure!

The part of the documentation you quoted is for Node but my code actually uses Package. In case a dependency is renamed, one can access the new name via the rename field of the dependency. This raises an interesting question: What happens if you use a local variant of a crate via renaming and another variant from crates.io? I am not quite sure which names should end up in the HashMap, in particular, this may be inconsistent accross transitive dependencies.

@messense

messense commented Dec 1, 2021

Copy link
Copy Markdown
Member Author

I've just added a transitive path dep test crate. The dependency graph is workspace_with_path_dep -> generic_lib -> transitive_lib and these are all path dependencies. The end result looks fine to me?

❯ tar -ztf dist/workspace_with_path_dep-0.1.0.tar.gz
workspace_with_path_dep-0.1.0/local_dependencies/generic_lib/Cargo.toml
workspace_with_path_dep-0.1.0/local_dependencies/generic_lib/src/lib.rs
workspace_with_path_dep-0.1.0/local_dependencies/transitive_lib/Cargo.toml
workspace_with_path_dep-0.1.0/local_dependencies/transitive_lib/src/lib.rs
workspace_with_path_dep-0.1.0/Cargo.toml
workspace_with_path_dep-0.1.0/pyproject.toml
workspace_with_path_dep-0.1.0/src/lib.rs
workspace_with_path_dep-0.1.0/PKG-INFO

@konstin konstin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

A test that compares the archive file list would be useful

@messense
messense force-pushed the workspace-path-dep branch 3 times, most recently from 802cb6d to 7e3c22f Compare December 1, 2021 13:33
@messense
messense merged commit 91b042a into PyO3:main Dec 1, 2021
@messense
messense deleted the workspace-path-dep branch December 1, 2021 14:00
wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request Jan 3, 2022
* Add support for repairing cross compiled linux wheels in [#754](PyO3/maturin#754)
* Add support for `manylinux_2_28` and `manylinux_2_31` in [#755](PyO3/maturin#755)
* Remove existing so file first in `maturin develop` command to avoid triggering SIGSEV in running process in [#760](PyO3/maturin#760)

* Fix docs for `new` and `init` commands in `maturin --help` in [#734](PyO3/maturin#734)
* Add support for x86_64 Haiku in [#735](PyO3/maturin#735)
* Fix undefined auditwheel policy panic in [#740](PyO3/maturin#740)
* Fix sdist upload for packages where the pkgname contains multiple underscores in [#741](PyO3/maturin#741)
* Implement auditwheel repair with patchelf in [#742](PyO3/maturin#742)
* Add `Cargo.lock` to sdist when `--locked` or `--frozen` specified in [#749](PyO3/maturin#749)
* Infer readme file if not specified in [#751](PyO3/maturin#751)

* Add a `maturin init` command as a companion to `maturin new` in [#719](PyO3/maturin#719)
* Don't package non-path-dep crates in sdist for workspaces in [#720](PyO3/maturin#720)
* Build release packages with `password-storage` feature in [#725](PyO3/maturin#725)
* Add support for x86_64 DargonFly BSD in [#727](PyO3/maturin#727)
* Add a Python import hook in [#729](PyO3/maturin#729)
* Allow pip warnings in `maturin develop` command in [#732](PyO3/maturin#732)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Additional non-path-dep crates are being packaged in workspaces, causing file not found errors

4 participants