mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Add --no-sources
to avoid reading from tool.uv.sources
(#5801)
## Summary Closes https://github.com/astral-sh/uv/issues/5791.
This commit is contained in:
parent
478d32c655
commit
089f50a845
27 changed files with 455 additions and 40 deletions
|
@ -7,7 +7,7 @@ use crate::metadata::lowering::LoweringError;
|
|||
pub use crate::metadata::requires_dist::RequiresDist;
|
||||
use pep440_rs::{Version, VersionSpecifiers};
|
||||
use pypi_types::{HashDigest, Metadata23};
|
||||
use uv_configuration::PreviewMode;
|
||||
use uv_configuration::{PreviewMode, SourceStrategy};
|
||||
use uv_normalize::{ExtraName, GroupName, PackageName};
|
||||
use uv_workspace::WorkspaceError;
|
||||
|
||||
|
@ -58,6 +58,7 @@ impl Metadata {
|
|||
metadata: Metadata23,
|
||||
install_path: &Path,
|
||||
lock_path: &Path,
|
||||
sources: SourceStrategy,
|
||||
preview_mode: PreviewMode,
|
||||
) -> Result<Self, MetadataError> {
|
||||
// Lower the requirements.
|
||||
|
@ -74,6 +75,7 @@ impl Metadata {
|
|||
},
|
||||
install_path,
|
||||
lock_path,
|
||||
sources,
|
||||
preview_mode,
|
||||
)
|
||||
.await?;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
|
||||
use uv_configuration::PreviewMode;
|
||||
use uv_configuration::{PreviewMode, SourceStrategy};
|
||||
use uv_normalize::{ExtraName, GroupName, PackageName, DEV_DEPENDENCIES};
|
||||
use uv_workspace::{DiscoveryOptions, ProjectWorkspace};
|
||||
|
||||
|
@ -39,21 +39,27 @@ impl RequiresDist {
|
|||
metadata: pypi_types::RequiresDist,
|
||||
install_path: &Path,
|
||||
lock_path: &Path,
|
||||
sources: SourceStrategy,
|
||||
preview_mode: PreviewMode,
|
||||
) -> Result<Self, MetadataError> {
|
||||
// TODO(konsti): Limit discovery for Git checkouts to Git root.
|
||||
// TODO(konsti): Cache workspace discovery.
|
||||
let Some(project_workspace) = ProjectWorkspace::from_maybe_project_root(
|
||||
install_path,
|
||||
lock_path,
|
||||
&DiscoveryOptions::default(),
|
||||
)
|
||||
.await?
|
||||
else {
|
||||
return Ok(Self::from_metadata23(metadata));
|
||||
};
|
||||
match sources {
|
||||
SourceStrategy::Enabled => {
|
||||
// TODO(konsti): Limit discovery for Git checkouts to Git root.
|
||||
// TODO(konsti): Cache workspace discovery.
|
||||
let Some(project_workspace) = ProjectWorkspace::from_maybe_project_root(
|
||||
install_path,
|
||||
lock_path,
|
||||
&DiscoveryOptions::default(),
|
||||
)
|
||||
.await?
|
||||
else {
|
||||
return Ok(Self::from_metadata23(metadata));
|
||||
};
|
||||
|
||||
Self::from_project_workspace(metadata, &project_workspace, preview_mode)
|
||||
Self::from_project_workspace(metadata, &project_workspace, preview_mode)
|
||||
}
|
||||
SourceStrategy::Disabled => Ok(Self::from_metadata23(metadata)),
|
||||
}
|
||||
}
|
||||
|
||||
fn from_project_workspace(
|
||||
|
|
|
@ -46,8 +46,8 @@ mod revision;
|
|||
/// Fetch and build a source distribution from a remote source, or from a local cache.
|
||||
pub(crate) struct SourceDistributionBuilder<'a, T: BuildContext> {
|
||||
build_context: &'a T,
|
||||
reporter: Option<Arc<dyn Reporter>>,
|
||||
preview_mode: PreviewMode,
|
||||
reporter: Option<Arc<dyn Reporter>>,
|
||||
}
|
||||
|
||||
/// The name of the file that contains the revision ID for a remote distribution, encoded via `MsgPack`.
|
||||
|
@ -64,8 +64,8 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
pub(crate) fn new(build_context: &'a T, preview_mode: PreviewMode) -> Self {
|
||||
Self {
|
||||
build_context,
|
||||
reporter: None,
|
||||
preview_mode,
|
||||
reporter: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,6 +426,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
requires_dist,
|
||||
project_root,
|
||||
project_root,
|
||||
self.build_context.sources(),
|
||||
self.preview_mode,
|
||||
)
|
||||
.await?;
|
||||
|
@ -990,6 +991,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
metadata,
|
||||
resource.install_path.as_ref(),
|
||||
resource.lock_path.as_ref(),
|
||||
self.build_context.sources(),
|
||||
self.preview_mode,
|
||||
)
|
||||
.await?,
|
||||
|
@ -1015,6 +1017,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
metadata,
|
||||
resource.install_path.as_ref(),
|
||||
resource.lock_path.as_ref(),
|
||||
self.build_context.sources(),
|
||||
self.preview_mode,
|
||||
)
|
||||
.await?,
|
||||
|
@ -1047,6 +1050,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
metadata,
|
||||
resource.install_path.as_ref(),
|
||||
resource.lock_path.as_ref(),
|
||||
self.build_context.sources(),
|
||||
self.preview_mode,
|
||||
)
|
||||
.await?,
|
||||
|
@ -1257,6 +1261,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
metadata,
|
||||
fetch.path(),
|
||||
fetch.path(),
|
||||
self.build_context.sources(),
|
||||
self.preview_mode,
|
||||
)
|
||||
.await?,
|
||||
|
@ -1279,8 +1284,14 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
.map_err(Error::CacheWrite)?;
|
||||
|
||||
return Ok(ArchiveMetadata::from(
|
||||
Metadata::from_workspace(metadata, fetch.path(), fetch.path(), self.preview_mode)
|
||||
.await?,
|
||||
Metadata::from_workspace(
|
||||
metadata,
|
||||
fetch.path(),
|
||||
fetch.path(),
|
||||
self.build_context.sources(),
|
||||
self.preview_mode,
|
||||
)
|
||||
.await?,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -1306,8 +1317,14 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
|
|||
.map_err(Error::CacheWrite)?;
|
||||
|
||||
Ok(ArchiveMetadata::from(
|
||||
Metadata::from_workspace(metadata, fetch.path(), fetch.path(), self.preview_mode)
|
||||
.await?,
|
||||
Metadata::from_workspace(
|
||||
metadata,
|
||||
fetch.path(),
|
||||
fetch.path(),
|
||||
self.build_context.sources(),
|
||||
self.preview_mode,
|
||||
)
|
||||
.await?,
|
||||
))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue