Show More
@@ -732,16 +732,23 b' class InteractiveShell(SingletonConfigurable):' | |||
|
732 | 732 | # Not in a virtualenv |
|
733 | 733 | return |
|
734 | 734 | |
|
735 | # venv detection: | |
|
735 | p = os.path.normcase(sys.executable) | |
|
736 | p_venv = os.path.normcase(os.environ['VIRTUAL_ENV']) | |
|
737 | ||
|
738 | # executable path should end like /bin/python or \\scripts\\python.exe | |
|
739 | p_exe_up2 = os.path.dirname(os.path.dirname(p)) | |
|
740 | if p_exe_up2 and os.path.samefile(p_exe_up2, p_venv): | |
|
741 | # Our exe is inside the virtualenv, don't need to do anything. | |
|
742 | return | |
|
743 | ||
|
744 | # fallback venv detection: | |
|
736 | 745 | # stdlib venv may symlink sys.executable, so we can't use realpath. |
|
737 | 746 | # but others can symlink *to* the venv Python, so we can't just use sys.executable. |
|
738 | 747 | # So we just check every item in the symlink tree (generally <= 3) |
|
739 | p = os.path.normcase(sys.executable) | |
|
740 | 748 | paths = [p] |
|
741 | 749 | while os.path.islink(p): |
|
742 | 750 | p = os.path.normcase(os.path.join(os.path.dirname(p), os.readlink(p))) |
|
743 | 751 | paths.append(p) |
|
744 | p_venv = os.path.normcase(os.environ['VIRTUAL_ENV']) | |
|
745 | 752 | |
|
746 | 753 | # In Cygwin paths like "c:\..." and '\cygdrive\c\...' are possible |
|
747 | 754 | if p_venv.startswith('\\cygdrive'): |
General Comments 0
You need to be logged in to leave comments.
Login now