@@ -20,6 +20,7 @@ use uv_platform::{Error as PlatformError, Os};
2020use uv_platform:: { LibcDetectionError , Platform } ;
2121use uv_state:: { StateBucket , StateStore } ;
2222use uv_static:: EnvVars ;
23+ use uv_trampoline_builder:: { Launcher , LauncherKind } ;
2324
2425use crate :: downloads:: { Error as DownloadError , ManagedPythonDownload } ;
2526use crate :: implementation:: {
@@ -92,7 +93,6 @@ pub enum Error {
9293 } ,
9394 #[ error( "Failed to find a directory to install executables into" ) ]
9495 NoExecutableDirectory ,
95- #[ cfg( windows) ]
9696 #[ error( transparent) ]
9797 LauncherError ( #[ from] uv_trampoline_builder:: Error ) ,
9898 #[ error( "Failed to read managed Python directory name: {0}" ) ]
@@ -619,13 +619,9 @@ impl ManagedPythonInstallation {
619619 /// Returns `true` if the path is a link to this installation's binary, e.g., as created by
620620 /// [`create_bin_link`].
621621 pub fn is_bin_link ( & self , path : & Path ) -> bool {
622- #[ cfg( unix) ]
623- {
622+ if cfg ! ( unix) {
624623 same_file:: is_same_file ( path, self . executable ( false ) ) . unwrap_or_default ( )
625- }
626- #[ cfg( windows) ]
627- {
628- use uv_trampoline_builder:: { Launcher , LauncherKind } ;
624+ } else if cfg ! ( windows) {
629625 let Some ( launcher) = Launcher :: try_from_path ( path) . unwrap_or_default ( ) else {
630626 return false ;
631627 } ;
@@ -637,9 +633,7 @@ impl ManagedPythonInstallation {
637633 // directly.
638634 dunce:: canonicalize ( & launcher. python_path ) . unwrap_or ( launcher. python_path )
639635 == self . executable ( false )
640- }
641- #[ cfg( not( any( unix, windows) ) ) ]
642- {
636+ } else {
643637 unreachable ! ( "Only Windows and Unix are supported" )
644638 }
645639 }
@@ -882,8 +876,7 @@ pub fn create_link_to_executable(link: &Path, executable: &Path) -> Result<(), E
882876 err,
883877 } ) ?;
884878
885- #[ cfg( unix) ]
886- {
879+ if cfg ! ( unix) {
887880 // Note this will never copy on Unix — we use it here to allow compilation on Windows
888881 match symlink_or_copy_file ( executable, link) {
889882 Ok ( ( ) ) => Ok ( ( ) ) ,
@@ -896,9 +889,7 @@ pub fn create_link_to_executable(link: &Path, executable: &Path) -> Result<(), E
896889 err,
897890 } ) ,
898891 }
899- }
900- #[ cfg( windows) ]
901- {
892+ } else if cfg ! ( windows) {
902893 use uv_trampoline_builder:: windows_python_launcher;
903894
904895 // TODO(zanieb): Install GUI launchers as well
@@ -916,10 +907,8 @@ pub fn create_link_to_executable(link: &Path, executable: &Path) -> Result<(), E
916907 err,
917908 } )
918909 }
919- }
920- #[ cfg( not( any( unix, windows) ) ) ]
921- {
922- unimplemented ! ( "Only Windows and Unix systems are supported." )
910+ } else {
911+ unimplemented ! ( "Only Windows and Unix are supported." )
923912 }
924913}
925914
0 commit comments