@@ -162,6 +162,18 @@ fn find_uv_python(python_path: &Path) -> Result<(PathBuf, Vec<&'static str>)> {
162162 }
163163}
164164
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+
165177/// Install the crate as module in the current virtualenv
166178#[ derive( Debug , clap:: Parser ) ]
167179pub struct DevelopOptions {
@@ -312,7 +324,7 @@ fn configure_as_editable(
312324 python : & Path ,
313325 install_backend : & InstallBackend ,
314326) -> Result < ( ) > {
315- println ! ( "✏️ Setting installed package as editable" ) ;
327+ println ! ( "✏️ Setting installed package as editable" ) ;
316328 install_backend. check_supports_show_files ( python) ?;
317329 let mut cmd = install_backend. make_command ( python) ;
318330 let cmd = cmd. args ( [ "show" , "--files" , & build_context. metadata24 . name ] ) ;
@@ -418,10 +430,24 @@ pub fn develop(develop_options: DevelopOptions, venv_dir: &Path) -> Result<()> {
418430 || anyhow ! ( "Expected `python` to be a python interpreter inside a virtualenv ಠ_ಠ" ) ,
419431 ) ?;
420432
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?;
425451 InstallBackend :: Uv {
426452 path : uv_path,
427453 args : uv_args,
0 commit comments