Show More
@@ -716,9 +716,16 b' class InteractiveShell(SingletonConfigurable):' | |||
|
716 | 716 | # Not in a virtualenv |
|
717 | 717 | return |
|
718 | 718 | |
|
719 | if os.path.realpath(sys.executable).startswith( | |
|
720 | os.path.realpath(os.environ['VIRTUAL_ENV']) | |
|
721 | ): | |
|
719 | # venv detection: | |
|
720 | # stdlib venv may symlink sys.executable, so we can't use realpath. | |
|
721 | # but others can symlink *to* the venv Python, so we can't just use sys.executable. | |
|
722 | # So we just check every item in the symlink tree (generally <= 3) | |
|
723 | p = sys.executable | |
|
724 | paths = [p] | |
|
725 | while os.path.islink(p): | |
|
726 | p = os.path.join(os.path.dirname(p), os.readlink(p)) | |
|
727 | paths.append(p) | |
|
728 | if any(p.startswith(os.environ['VIRTUAL_ENV']) for p in paths): | |
|
722 | 729 | # Running properly in the virtualenv, don't need to do anything |
|
723 | 730 | return |
|
724 | 731 |
General Comments 0
You need to be logged in to leave comments.
Login now