##// END OF EJS Templates
Merge pull request #4737 from minrk/venv-symlinks...
Thomas Kluyver -
r13968:c0ea28ff merge
parent child Browse files
Show More
@@ -716,9 +716,16 b' class InteractiveShell(SingletonConfigurable):'
716 # Not in a virtualenv
716 # Not in a virtualenv
717 return
717 return
718
718
719 if os.path.realpath(sys.executable).startswith(
719 # venv detection:
720 os.path.realpath(os.environ['VIRTUAL_ENV'])
720 # stdlib venv may symlink sys.executable, so we can't use realpath.
721 ):
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 # Running properly in the virtualenv, don't need to do anything
729 # Running properly in the virtualenv, don't need to do anything
723 return
730 return
724
731
General Comments 0
You need to be logged in to leave comments. Login now