-
Notifications
You must be signed in to change notification settings - Fork 3k
Add module owners to workspace metadata #19122
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8028,6 +8028,13 @@ pub struct MetadataArgs { | |||||
| #[command(flatten)] | ||||||
| pub refresh: RefreshArgs, | ||||||
|
|
||||||
| /// Include module ownership metadata in the output. | ||||||
| /// | ||||||
| /// This adds a mapping from importable module names to the package names that provide | ||||||
| /// them. To do this, the venv will be synced in "inexact" mode. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| #[arg(long)] | ||||||
| pub module_owners: bool, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might prefer |
||||||
|
|
||||||
| /// The Python interpreter to use during resolution. | ||||||
| /// | ||||||
| /// A Python interpreter is required for building source distributions to determine package | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| use std::collections::BTreeMap; | ||
| use std::fmt::Display; | ||
|
|
||
| /// The name of an importable Python module. | ||
| type ModuleName = String; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about |
||
|
|
||
| use uv_distribution_filename::WheelFilename; | ||
| use uv_distribution_types::{RequiresPython, UrlString}; | ||
| use uv_fs::PortablePathBuf; | ||
|
|
@@ -66,6 +69,9 @@ pub struct Metadata { | |
| requires_python: RequiresPython, | ||
| /// Info about conflicting packages | ||
| conflicts: MetadataConflicts, | ||
| /// A mapping from importable module names to the distributions that provide them | ||
| #[serde(skip_serializing_if = "BTreeMap::is_empty", default)] | ||
| module_owners: BTreeMap<ModuleName, Vec<PackageName>>, | ||
|
Comment on lines
+72
to
+74
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd probably reverse key and value in this map and make it package centric, in the sense that all metadata is attached to package node(s), rather than the other thing pointing towards a package. |
||
| /// An index of which nodes are workspace members | ||
| /// | ||
| /// These entries are often what you should use as the entry-points into the `resolve` graph. | ||
|
|
@@ -818,13 +824,23 @@ impl Metadata { | |
| version: SchemaVersion::Preview, | ||
| }, | ||
| conflicts, | ||
| module_owners: BTreeMap::new(), | ||
| workspace_root, | ||
| requires_python: lock.requires_python.clone(), | ||
| members, | ||
| resolution: resolve, | ||
| }) | ||
| } | ||
|
|
||
| #[must_use] | ||
| pub fn with_module_owners( | ||
| mut self, | ||
| module_owners: BTreeMap<ModuleName, Vec<PackageName>>, | ||
| ) -> Self { | ||
| self.module_owners = module_owners; | ||
| self | ||
| } | ||
|
|
||
| pub fn to_json(&self) -> Result<String, MetadataError> { | ||
| Ok(serde_json::to_string_pretty(self)?) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| pub(crate) mod dir; | ||
| pub(crate) mod list; | ||
| pub(crate) mod metadata; | ||
| mod module_owners; |
Uh oh!
There was an error while loading. Please reload this page.