@@ -162,6 +162,18 @@ fn find_uv_python(python_path: &Path) -> Result<(PathBuf, Vec<&'static str>)> {
162
162
}
163
163
}
164
164
165
+ /// Check if a virtualenv is created by uv by reading pyvenv.cfg
166
+ fn is_uv_venv ( venv_dir : & Path ) -> bool {
167
+ let pyvenv_cfg = venv_dir. join ( "pyvenv.cfg" ) ;
168
+ if !pyvenv_cfg. exists ( ) {
169
+ return false ;
170
+ }
171
+ match fs:: read_to_string ( & pyvenv_cfg) {
172
+ Ok ( content) => content. contains ( "\n uv = " ) ,
173
+ Err ( _) => false ,
174
+ }
175
+ }
176
+
165
177
/// Install the crate as module in the current virtualenv
166
178
#[ derive( Debug , clap:: Parser ) ]
167
179
pub struct DevelopOptions {
@@ -312,7 +324,7 @@ fn configure_as_editable(
312
324
python : & Path ,
313
325
install_backend : & InstallBackend ,
314
326
) -> Result < ( ) > {
315
- println ! ( "✏️ Setting installed package as editable" ) ;
327
+ println ! ( "✏️ Setting installed package as editable" ) ;
316
328
install_backend. check_supports_show_files ( python) ?;
317
329
let mut cmd = install_backend. make_command ( python) ;
318
330
let cmd = cmd. args ( [ "show" , "--files" , & build_context. metadata24 . name ] ) ;
@@ -418,10 +430,24 @@ pub fn develop(develop_options: DevelopOptions, venv_dir: &Path) -> Result<()> {
418
430
|| anyhow ! ( "Expected `python` to be a python interpreter inside a virtualenv ಠ_ಠ" ) ,
419
431
) ?;
420
432
421
- let install_backend = if uv {
422
- let ( uv_path, uv_args) = find_uv_python ( & interpreter. executable )
423
- . or_else ( |_| find_uv_bin ( ) )
424
- . context ( "Failed to find uv" ) ?;
433
+ let uv_venv = is_uv_venv ( venv_dir) ;
434
+ let uv_info = if uv || uv_venv {
435
+ match find_uv_python ( & interpreter. executable ) . or_else ( |_| find_uv_bin ( ) ) {
436
+ Ok ( uv_info) => Some ( Ok ( uv_info) ) ,
437
+ Err ( e) => {
438
+ if uv {
439
+ Some ( Err ( e) )
440
+ } else {
441
+ // Ignore error and try pip instead if it's a uv venv but `--uv` is not specified
442
+ None
443
+ }
444
+ }
445
+ }
446
+ } else {
447
+ None
448
+ } ;
449
+ let install_backend = if let Some ( uv_info) = uv_info {
450
+ let ( uv_path, uv_args) = uv_info?;
425
451
InstallBackend :: Uv {
426
452
path : uv_path,
427
453
args : uv_args,
0 commit comments