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

Discover workspaces without using them in resolution #3585

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion crates/uv-requirements/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ schemars = ["dep:schemars"]

[dev-dependencies]
indoc = "2.0.5"
insta = "1.38.0"
insta = { version = "1.38.0", features = ["filters", "redactions", "json"] }
regex = { workspace = true }

[lints]
workspace = true
2 changes: 2 additions & 0 deletions crates/uv-requirements/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub use crate::source_tree::*;
pub use crate::sources::*;
pub use crate::specification::*;
pub use crate::unnamed::*;
pub use crate::workspace::*;

mod confirm;
mod lookahead;
Expand All @@ -12,3 +13,4 @@ mod sources;
mod specification;
mod unnamed;
pub mod upgrade;
mod workspace;
22 changes: 11 additions & 11 deletions crates/uv-requirements/src/pyproject.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Reads the following fields from from `pyproject.toml`:
//! Reads the following fields from `pyproject.toml`:
//!
//! * `project.{dependencies,optional-dependencies}`
//! * `tool.uv.sources`
//! * `tool.uv.workspace`
//!
//! Then lowers them into a dependency specification.

use std::collections::HashMap;
use std::collections::BTreeMap;
use std::io;
Copy link
Member Author

Choose a reason for hiding this comment

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

This makes the test snapshots deterministic

use std::ops::Deref;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -110,7 +110,7 @@ pub struct Tool {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub struct ToolUv {
pub sources: Option<HashMap<PackageName, Source>>,
pub sources: Option<BTreeMap<PackageName, Source>>,
pub workspace: Option<ToolUvWorkspace>,
}

Expand Down Expand Up @@ -238,8 +238,8 @@ impl Pep621Metadata {
extras: &ExtrasSpecification,
pyproject_path: &Path,
project_dir: &Path,
workspace_sources: &HashMap<PackageName, Source>,
workspace_packages: &HashMap<PackageName, String>,
workspace_sources: &BTreeMap<PackageName, Source>,
workspace_packages: &BTreeMap<PackageName, String>,
preview: PreviewMode,
) -> Result<Option<Self>, Pep621Error> {
let project_sources = pyproject
Expand Down Expand Up @@ -323,9 +323,9 @@ pub(crate) fn lower_requirements(
pyproject_path: &Path,
project_name: &PackageName,
project_dir: &Path,
project_sources: &HashMap<PackageName, Source>,
workspace_sources: &HashMap<PackageName, Source>,
workspace_packages: &HashMap<PackageName, String>,
project_sources: &BTreeMap<PackageName, Source>,
workspace_sources: &BTreeMap<PackageName, Source>,
workspace_packages: &BTreeMap<PackageName, String>,
preview: PreviewMode,
) -> Result<Requirements, Pep621Error> {
let dependencies = dependencies
Expand Down Expand Up @@ -386,9 +386,9 @@ pub(crate) fn lower_requirement(
requirement: pep508_rs::Requirement,
project_name: &PackageName,
project_dir: &Path,
project_sources: &HashMap<PackageName, Source>,
workspace_sources: &HashMap<PackageName, Source>,
workspace_packages: &HashMap<PackageName, String>,
project_sources: &BTreeMap<PackageName, Source>,
workspace_sources: &BTreeMap<PackageName, Source>,
workspace_packages: &BTreeMap<PackageName, String>,
preview: PreviewMode,
) -> Result<Requirement, LoweringError> {
let source = project_sources
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-requirements/src/specification.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};

use anyhow::{Context, Result};
Expand Down Expand Up @@ -165,8 +165,8 @@ impl RequirementsSpecification {
.parent()
.context("`pyproject.toml` has no parent directory")?;

let workspace_sources = HashMap::default();
let workspace_packages = HashMap::default();
let workspace_sources = BTreeMap::default();
let workspace_packages = BTreeMap::default();
match Pep621Metadata::try_from(
pyproject,
extras,
Expand Down
Loading
Loading