mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add a helper to return the path to the real pytohn executable
In case the test suite is running from within a virtualenv
This commit is contained in:
parent
ea9d2460f0
commit
3d407e8a2e
1 changed files with 21 additions and 0 deletions
|
@ -12,6 +12,7 @@ from __future__ import absolute_import
|
|||
import fnmatch
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import fnmatch
|
||||
import tempfile
|
||||
|
||||
|
@ -153,3 +154,23 @@ def fail_function(*args, **kwargs): # pylint: disable=unused-argument
|
|||
Return False no matter what is passed to it
|
||||
'''
|
||||
return False
|
||||
|
||||
|
||||
def get_python_executable():
|
||||
'''
|
||||
Return the path to the python executable.
|
||||
|
||||
This is particularly important when running the test suite within a virtualenv, while trying
|
||||
to create virtualenvs on windows.
|
||||
'''
|
||||
try:
|
||||
if salt.utils.is_windows():
|
||||
python_binary = os.path.join(sys.real_prefix, os.path.basename(sys.executable))
|
||||
else:
|
||||
python_binary = os.path.join(sys.real_prefix, 'bin', os.path.basename(sys.executable))
|
||||
if not os.path.exists(python_binary):
|
||||
python_binary = None
|
||||
except AttributeError:
|
||||
# We're not running inside a virtualenv
|
||||
python_binary = None
|
||||
return python_binary
|
||||
|
|
Loading…
Add table
Reference in a new issue