@@ -32,11 +32,11 @@ use uv_distribution_filename::{
3232} ;
3333use uv_distribution_types:: {
3434 BuiltDist , DependencyMetadata , DirectUrlBuiltDist , DirectUrlSourceDist , DirectorySourceDist ,
35- Dist , FileLocation , GitDirectorySourceDist , GitPathBuiltDist , GitPathSourceDist , Identifier ,
36- IndexLocations , IndexMetadata , IndexUrl , Name , PYPI_URL , PathBuiltDist , PathSourceDist ,
37- RegistryBuiltDist , RegistryBuiltWheel , RegistrySourceDist , RemoteSource , Requirement ,
38- RequirementSource , RequiresPython , ResolvedDist , SimplifiedMarkerTree , StaticMetadata ,
39- ToUrlError , UrlString ,
35+ Dist , FileLocation , FirstParty , GitDirectorySourceDist , GitPathBuiltDist , GitPathSourceDist ,
36+ Identifier , IndexLocations , IndexMetadata , IndexUrl , Name , PYPI_URL , PathBuiltDist ,
37+ PathSourceDist , RegistryBuiltDist , RegistryBuiltWheel , RegistrySourceDist , RemoteSource ,
38+ Requirement , RequirementSource , RequiresPython , ResolvedDist , SimplifiedMarkerTree ,
39+ StaticMetadata , ToUrlError , UrlString ,
4040} ;
4141use uv_fs:: { PortablePath , PortablePathBuf , Simplified , normalize_path, try_relative_to_if} ;
4242use uv_git:: { RepositoryReference , ResolvedRepositoryReference } ;
@@ -1436,6 +1436,12 @@ impl Lock {
14361436 & self . manifest . members
14371437 }
14381438
1439+ /// Returns `true` if the package is a workspace member.
1440+ fn is_workspace_member ( & self , package : & Package ) -> bool {
1441+ self . members ( ) . contains ( & package. id . name )
1442+ || self . members ( ) . is_empty ( ) && self . root ( ) . is_some_and ( |root| root. id == package. id )
1443+ }
1444+
14391445 /// Returns the root requirements that were used to generate this lock.
14401446 fn requirements ( & self ) -> & BTreeSet < Requirement > {
14411447 & self . manifest . requirements
@@ -3181,8 +3187,13 @@ impl Lock {
31813187 index : & InMemoryIndex ,
31823188 database : & DistributionDatabase < ' _ , Context > ,
31833189 ) -> Result < DistributionMetadata , LockError > {
3184- let HashedDist { dist, .. } =
3185- package. to_dist ( root, TagPolicy :: Preferred ( tags) , build_options, markers) ?;
3190+ let HashedDist { dist, .. } = package. to_dist (
3191+ root,
3192+ TagPolicy :: Preferred ( tags) ,
3193+ build_options,
3194+ markers,
3195+ FirstParty :: No ,
3196+ ) ?;
31863197 let id = dist. distribution_id ( ) ;
31873198 if let Some ( archive) = index
31883199 . distributions ( )
@@ -3865,6 +3876,7 @@ impl Package {
38653876 tag_policy : TagPolicy < ' _ > ,
38663877 build_options : & BuildOptions ,
38673878 markers : & MarkerEnvironment ,
3879+ first_party : FirstParty ,
38683880 ) -> Result < HashedDist , LockError > {
38693881 let no_binary = build_options. no_binary_package ( & self . id . name ) ;
38703882 let no_build = build_options. no_build_package ( & self . id . name ) ;
@@ -3995,11 +4007,11 @@ impl Package {
39954007 }
39964008 }
39974009
3998- if let Some ( sdist) = self . to_source_dist ( workspace_root) ? {
3999- // Even with `--no-build`, allow virtual packages. (In the future, we may want to allow
4000- // any local source tree, or at least editable source trees, which we allow in
4001- // `uv pip`.)
4002- if !no_build || sdist. is_virtual ( ) {
4010+ if let Some ( sdist) = self . to_source_dist ( workspace_root, first_party ) ? {
4011+ // Even with `--no-build`, allow virtual packages and first-party workspace members. In
4012+ // the future, we may want to allow any local source tree, or at least editable source
4013+ // trees, as we do in `uv pip`.
4014+ if !no_build || sdist. is_virtual ( ) || sdist . is_first_party ( ) {
40034015 let hashes = self
40044016 . sdist
40054017 . as_ref ( )
@@ -4072,6 +4084,7 @@ impl Package {
40724084 fn to_source_dist (
40734085 & self ,
40744086 workspace_root : & Path ,
4087+ first_party : FirstParty ,
40754088 ) -> Result < Option < uv_distribution_types:: SourceDist > , LockError > {
40764089 let sdist = match & self . id . source {
40774090 Source :: Path ( path) => {
@@ -4111,6 +4124,7 @@ impl Package {
41114124 install_path : install_path. into_boxed_path ( ) ,
41124125 editable : Some ( false ) ,
41134126 r#virtual : Some ( false ) ,
4127+ first_party,
41144128 } ;
41154129 uv_distribution_types:: SourceDist :: Directory ( dir_dist)
41164130 }
@@ -4123,6 +4137,7 @@ impl Package {
41234137 install_path : install_path. into_boxed_path ( ) ,
41244138 editable : Some ( true ) ,
41254139 r#virtual : Some ( false ) ,
4140+ first_party,
41264141 } ;
41274142 uv_distribution_types:: SourceDist :: Directory ( dir_dist)
41284143 }
@@ -4135,6 +4150,7 @@ impl Package {
41354150 install_path : install_path. into_boxed_path ( ) ,
41364151 editable : Some ( false ) ,
41374152 r#virtual : Some ( true ) ,
4153+ first_party,
41384154 } ;
41394155 uv_distribution_types:: SourceDist :: Directory ( dir_dist)
41404156 }
0 commit comments