@@ -17,14 +17,27 @@ def is_type_checking():
1717 return TYPE_CHECKING
1818
1919
20+ def possibly_convert_to_windows_style_path (path ):
21+ if not isinstance (path , str ):
22+ path = str (path )
23+ # Check if the path is in Unix-style (Git Bash)
24+ if os .name == 'nt' :
25+ if path .startswith ('/' ):
26+ drive , tail = re .match (r"^/([a-zA-Z])/(.*)" , path ).groups ()
27+ revised_path = drive .upper () + ":\\ " + tail .replace ('/' , '\\ ' )
28+ return revised_path
29+ elif path .startswith ('\\ ' ):
30+ drive , tail = re .match (r"^\\([a-zA-Z])\\(.*)" , path ).groups ()
31+ revised_path = drive .upper () + ":\\ " + tail .replace ('\\ ' , '\\ ' )
32+ return revised_path
33+
34+ return path
35+
36+
2037PYENV_ROOT = os .path .expanduser (
2138 os .path .expandvars (os .environ .get ("PYENV_ROOT" , "~/.pyenv" ))
2239)
23- # Check if the path is in Unix-style (Git Bash)
24- if PYENV_ROOT .startswith ('/' ) and os .name == 'nt' :
25- # Convert to Windows-style path
26- drive , tail = re .match (r"^/([a-zA-Z])/(.*)" , PYENV_ROOT ).groups ()
27- PYENV_ROOT = drive .upper () + ":\\ " + tail .replace ('/' , '\\ ' )
40+ PYENV_ROOT = possibly_convert_to_windows_style_path (PYENV_ROOT )
2841PYENV_INSTALLED = shutil .which ("pyenv" ) != None
2942ASDF_DATA_DIR = os .path .expanduser (
3043 os .path .expandvars (os .environ .get ("ASDF_DATA_DIR" , "~/.asdf" ))
0 commit comments