mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
We need to make sure the virtualenv path entry is removed when searching
This commit is contained in:
parent
ff6d3c6dae
commit
7e79b182b6
1 changed files with 19 additions and 3 deletions
|
@ -764,11 +764,27 @@ class TestDaemon(object):
|
|||
# virtualenv, we can on linux but we will still point to the virtualenv binary
|
||||
# outside the virtualenv running the test suite, if that's the case.
|
||||
try:
|
||||
real_prefix = sys.real_prefix
|
||||
# The above attribute exists, this is a virtualenv
|
||||
if salt.utils.is_windows():
|
||||
virtualenv_binary = os.path.join(sys.real_prefix, 'Scripts', 'virtualenv.exe')
|
||||
virtualenv_binary = os.path.join(real_prefix, 'Scripts', 'virtualenv.exe')
|
||||
else:
|
||||
virtualenv_binary = os.path.join(sys.real_prefix, 'bin', 'virtualenv')
|
||||
if not os.path.exists(virtualenv_binary):
|
||||
# We need to remove the virtualenv from PATH or we'll get the virtualenv binary
|
||||
# from within the virtualenv, we don't want that
|
||||
path = os.environ.get('PATH')
|
||||
if path is not None:
|
||||
path_items = path.split(os.pathsep)
|
||||
for item in path_items[:]:
|
||||
if item.startswith(sys.base_prefix):
|
||||
path_items.remove(item)
|
||||
os.environ['PATH'] = os.pathsep.join(path_items)
|
||||
virtualenv_binary = salt.utils.which('virtualenv')
|
||||
if path is not None:
|
||||
# Restore previous environ PATH
|
||||
os.environ['PATH'] = path
|
||||
if not virtualenv_binary.startswith(real_prefix):
|
||||
virtualenv_binary = None
|
||||
if virtualenv_binary and not os.path.exists(virtualenv_binary):
|
||||
# It doesn't exist?!
|
||||
virtualenv_binary = None
|
||||
except AttributeError:
|
||||
|
|
Loading…
Add table
Reference in a new issue