@@ -125,24 +125,6 @@ fn find_uv_bin() -> Result<(PathBuf, Vec<&'static str>)> {
125
125
}
126
126
}
127
127
128
- fn check_pip_exists ( python_path : & Path , pip_path : Option < & PathBuf > ) -> Result < ( ) > {
129
- let output = if let Some ( pip_path) = pip_path {
130
- Command :: new ( pip_path) . args ( [ "--version" ] ) . output ( ) ?
131
- } else {
132
- Command :: new ( python_path)
133
- . args ( [ "-m" , "pip" , "--version" ] )
134
- . output ( ) ?
135
- } ;
136
- if output. status . success ( ) {
137
- let version_str =
138
- str:: from_utf8 ( & output. stdout ) . context ( "`pip --version` didn't return utf8 output" ) ?;
139
- debug ! ( version = %version_str, "Found pip" ) ;
140
- Ok ( ( ) )
141
- } else {
142
- bail ! ( "`pip --version` failed with status: {}" , output. status) ;
143
- }
144
- }
145
-
146
128
/// Detect the Python uv package
147
129
fn find_uv_python ( python_path : & Path ) -> Result < ( PathBuf , Vec < & ' static str > ) > {
148
130
let output = Command :: new ( python_path)
@@ -162,6 +144,24 @@ fn find_uv_python(python_path: &Path) -> Result<(PathBuf, Vec<&'static str>)> {
162
144
}
163
145
}
164
146
147
+ fn check_pip_exists ( python_path : & Path , pip_path : Option < & PathBuf > ) -> Result < ( ) > {
148
+ let output = if let Some ( pip_path) = pip_path {
149
+ Command :: new ( pip_path) . args ( [ "--version" ] ) . output ( ) ?
150
+ } else {
151
+ Command :: new ( python_path)
152
+ . args ( [ "-m" , "pip" , "--version" ] )
153
+ . output ( ) ?
154
+ } ;
155
+ if output. status . success ( ) {
156
+ let version_str =
157
+ str:: from_utf8 ( & output. stdout ) . context ( "`pip --version` didn't return utf8 output" ) ?;
158
+ debug ! ( version = %version_str, "Found pip" ) ;
159
+ Ok ( ( ) )
160
+ } else {
161
+ bail ! ( "`pip --version` failed with status: {}" , output. status) ;
162
+ }
163
+ }
164
+
165
165
/// Check if a virtualenv is created by uv by reading pyvenv.cfg
166
166
fn is_uv_venv ( venv_dir : & Path ) -> bool {
167
167
let pyvenv_cfg = venv_dir. join ( "pyvenv.cfg" ) ;
@@ -224,7 +224,8 @@ pub struct DevelopOptions {
224
224
fn install_dependencies (
225
225
build_context : & BuildContext ,
226
226
extras : & [ String ] ,
227
- interpreter : & PythonInterpreter ,
227
+ python : & Path ,
228
+ venv_dir : & Path ,
228
229
install_backend : & InstallBackend ,
229
230
) -> Result < ( ) > {
230
231
if !build_context. metadata24 . requires_dist . is_empty ( ) {
@@ -256,12 +257,17 @@ fn install_dependencies(
256
257
pkg. to_string ( )
257
258
} ) ) ;
258
259
let status = install_backend
259
- . make_command ( & interpreter . executable )
260
+ . make_command ( python )
260
261
. args ( & args)
262
+ . env ( "VIRTUAL_ENV" , venv_dir)
261
263
. status ( )
262
- . context ( "Failed to run pip install" ) ?;
264
+ . with_context ( || format ! ( "Failed to run {} install" , install_backend . name ( ) ) ) ?;
263
265
if !status. success ( ) {
264
- bail ! ( r#"pip install finished with "{}""# , status)
266
+ bail ! (
267
+ r#"{} install finished with "{}""# ,
268
+ install_backend. name( ) ,
269
+ status
270
+ )
265
271
}
266
272
}
267
273
Ok ( ( ) )
@@ -279,6 +285,7 @@ fn install_wheel(
279
285
let output = cmd
280
286
. args ( [ "install" , "--no-deps" , "--force-reinstall" ] )
281
287
. arg ( dunce:: simplified ( wheel_filename) )
288
+ . env ( "VIRTUAL_ENV" , venv_dir)
282
289
. output ( )
283
290
. context ( format ! (
284
291
"{} install failed (ran {:?} with {:?})" ,
@@ -460,7 +467,7 @@ pub fn develop(develop_options: DevelopOptions, venv_dir: &Path) -> Result<()> {
460
467
}
461
468
} ;
462
469
463
- install_dependencies ( & build_context, & extras, & interpreter , & install_backend) ?;
470
+ install_dependencies ( & build_context, & extras, & python , venv_dir , & install_backend) ?;
464
471
465
472
let wheels = build_context. build_wheels ( ) ?;
466
473
if !skip_install {
0 commit comments