Show More
@@ -732,26 +732,16 b' class InteractiveShell(SingletonConfigurable):' | |||||
732 | # Not in a virtualenv |
|
732 | # Not in a virtualenv | |
733 | return |
|
733 | return | |
734 |
|
734 | |||
735 | # Handle no symbolic link case first. |
|
|||
736 | if not os.path.islink(sys.executable): |
|
|||
737 | # Adapted from pip.locations.running_under_virtualenv |
|
|||
738 | if hasattr(sys, 'real_prefix'): |
|
|||
739 | # Running properly in a virtualenv |
|
|||
740 | return |
|
|||
741 | elif sys.prefix != getattr(sys, "base_prefix", sys.prefix): |
|
|||
742 | # Running properly in a venv |
|
|||
743 | return |
|
|||
744 |
|
||||
745 | # venv detection: |
|
735 | # venv detection: | |
746 | # stdlib venv may symlink sys.executable, so we can't use realpath. |
|
736 | # stdlib venv may symlink sys.executable, so we can't use realpath. | |
747 | # but others can symlink *to* the venv Python, so we can't just use sys.executable. |
|
737 | # but others can symlink *to* the venv Python, so we can't just use sys.executable. | |
748 | # So we just check every item in the symlink tree (generally <= 3) |
|
738 | # So we just check every item in the symlink tree (generally <= 3) | |
749 | p = sys.executable |
|
739 | p = os.path.normcase(sys.executable) | |
750 | paths = [p] |
|
740 | paths = [p] | |
751 | while os.path.islink(p): |
|
741 | while os.path.islink(p): | |
752 | p = os.path.join(os.path.dirname(p), os.readlink(p)) |
|
742 | p = os.path.normcase(os.path.join(os.path.dirname(p), os.readlink(p))) | |
753 | paths.append(p) |
|
743 | paths.append(p) | |
754 | if any(p.startswith(os.environ['VIRTUAL_ENV']) for p in paths): |
|
744 | if any(p.startswith(os.path.normcase(os.environ['VIRTUAL_ENV'])) for p in paths): | |
755 | # Running properly in the virtualenv, don't need to do anything |
|
745 | # Running properly in the virtualenv, don't need to do anything | |
756 | return |
|
746 | return | |
757 |
|
747 |
General Comments 0
You need to be logged in to leave comments.
Login now