@@ -5,8 +5,8 @@ use uv_cache_info::CacheInfo;
55use uv_cache_key:: cache_digest;
66use uv_configuration:: { ConfigSettings , PackageConfigSettings } ;
77use uv_distribution_types:: {
8- DirectUrlSourceDist , DirectorySourceDist , ExtraBuildRequirement , ExtraBuildRequires ,
9- GitSourceDist , Hashed , PathSourceDist ,
8+ BuildVariables , DirectUrlSourceDist , DirectorySourceDist , ExtraBuildRequirement ,
9+ ExtraBuildRequires , ExtraBuildVariables , GitSourceDist , Hashed , PathSourceDist ,
1010} ;
1111use uv_normalize:: PackageName ;
1212use uv_platform_tags:: Tags ;
@@ -25,6 +25,7 @@ pub struct BuiltWheelIndex<'a> {
2525 config_settings : & ' a ConfigSettings ,
2626 config_settings_package : & ' a PackageConfigSettings ,
2727 extra_build_requires : & ' a ExtraBuildRequires ,
28+ extra_build_variables : & ' a ExtraBuildVariables ,
2829}
2930
3031impl < ' a > BuiltWheelIndex < ' a > {
@@ -36,6 +37,7 @@ impl<'a> BuiltWheelIndex<'a> {
3637 config_settings : & ' a ConfigSettings ,
3738 config_settings_package : & ' a PackageConfigSettings ,
3839 extra_build_requires : & ' a ExtraBuildRequires ,
40+ extra_build_variables : & ' a ExtraBuildVariables ,
3941 ) -> Self {
4042 Self {
4143 cache,
@@ -44,6 +46,7 @@ impl<'a> BuiltWheelIndex<'a> {
4446 config_settings,
4547 config_settings_package,
4648 extra_build_requires,
49+ extra_build_variables,
4750 }
4851 }
4952
@@ -75,10 +78,18 @@ impl<'a> BuiltWheelIndex<'a> {
7578 // If there are build settings, we need to scope to a cache shard.
7679 let config_settings = self . config_settings_for ( & source_dist. name ) ;
7780 let extra_build_deps = self . extra_build_requires_for ( & source_dist. name ) ;
78- let cache_shard = if config_settings. is_empty ( ) && extra_build_deps. is_empty ( ) {
81+ let extra_build_vars = self . extra_build_variables_for ( & source_dist. name ) ;
82+ let cache_shard = if config_settings. is_empty ( )
83+ && extra_build_deps. is_empty ( )
84+ && extra_build_vars. is_none ( )
85+ {
7986 cache_shard
8087 } else {
81- cache_shard. shard ( cache_digest ( & ( & config_settings, extra_build_deps) ) )
88+ cache_shard. shard ( cache_digest ( & (
89+ & config_settings,
90+ extra_build_deps,
91+ extra_build_vars,
92+ ) ) )
8293 } ;
8394
8495 Ok ( self . find ( & cache_shard) )
@@ -114,10 +125,18 @@ impl<'a> BuiltWheelIndex<'a> {
114125 // If there are build settings, we need to scope to a cache shard.
115126 let config_settings = self . config_settings_for ( & source_dist. name ) ;
116127 let extra_build_deps = self . extra_build_requires_for ( & source_dist. name ) ;
117- let cache_shard = if config_settings. is_empty ( ) && extra_build_deps. is_empty ( ) {
128+ let extra_build_vars = self . extra_build_variables_for ( & source_dist. name ) ;
129+ let cache_shard = if config_settings. is_empty ( )
130+ && extra_build_deps. is_empty ( )
131+ && extra_build_vars. is_none ( )
132+ {
118133 cache_shard
119134 } else {
120- cache_shard. shard ( cache_digest ( & ( & config_settings, extra_build_deps) ) )
135+ cache_shard. shard ( cache_digest ( & (
136+ & config_settings,
137+ extra_build_deps,
138+ extra_build_vars,
139+ ) ) )
121140 } ;
122141
123142 Ok ( self
@@ -164,10 +183,18 @@ impl<'a> BuiltWheelIndex<'a> {
164183 // If there are build settings, we need to scope to a cache shard.
165184 let config_settings = self . config_settings_for ( & source_dist. name ) ;
166185 let extra_build_deps = self . extra_build_requires_for ( & source_dist. name ) ;
167- let cache_shard = if config_settings. is_empty ( ) && extra_build_deps. is_empty ( ) {
186+ let extra_build_vars = self . extra_build_variables_for ( & source_dist. name ) ;
187+ let cache_shard = if config_settings. is_empty ( )
188+ && extra_build_deps. is_empty ( )
189+ && extra_build_vars. is_none ( )
190+ {
168191 cache_shard
169192 } else {
170- cache_shard. shard ( cache_digest ( & ( & config_settings, extra_build_deps) ) )
193+ cache_shard. shard ( cache_digest ( & (
194+ & config_settings,
195+ extra_build_deps,
196+ extra_build_vars,
197+ ) ) )
171198 } ;
172199
173200 Ok ( self
@@ -192,10 +219,18 @@ impl<'a> BuiltWheelIndex<'a> {
192219 // If there are build settings, we need to scope to a cache shard.
193220 let config_settings = self . config_settings_for ( & source_dist. name ) ;
194221 let extra_build_deps = self . extra_build_requires_for ( & source_dist. name ) ;
195- let cache_shard = if config_settings. is_empty ( ) && extra_build_deps. is_empty ( ) {
222+ let extra_build_vars = self . extra_build_variables_for ( & source_dist. name ) ;
223+ let cache_shard = if config_settings. is_empty ( )
224+ && extra_build_deps. is_empty ( )
225+ && extra_build_vars. is_none ( )
226+ {
196227 cache_shard
197228 } else {
198- cache_shard. shard ( cache_digest ( & ( & config_settings, extra_build_deps) ) )
229+ cache_shard. shard ( cache_digest ( & (
230+ & config_settings,
231+ extra_build_deps,
232+ extra_build_vars,
233+ ) ) )
199234 } ;
200235
201236 self . find ( & cache_shard)
@@ -274,4 +309,9 @@ impl<'a> BuiltWheelIndex<'a> {
274309 . map ( Vec :: as_slice)
275310 . unwrap_or ( & [ ] )
276311 }
312+
313+ /// Determine the extra build variables for the given package name.
314+ fn extra_build_variables_for ( & self , name : & PackageName ) -> Option < & BuildVariables > {
315+ self . extra_build_variables . get ( name)
316+ }
277317}
0 commit comments