Merge pull request #55171 from s0undt3ch/master

Try to use the same version matching python binary
This commit is contained in:
Daniel Wozniak 2019-11-03 12:01:45 -07:00 committed by GitHub
commit 9bbbd36294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View File

@ -68,7 +68,22 @@ class PipModuleTest(ModuleCase):
if salt.utils.is_windows():
python = os.path.join(sys.real_prefix, os.path.basename(sys.executable))
else:
python = os.path.join(sys.real_prefix, 'bin', os.path.basename(sys.executable))
python_binary_names = [
'python{}.{}'.format(*sys.version_info),
'python{}'.format(*sys.version_info),
'python'
]
for binary_name in python_binary_names:
python = os.path.join(sys.real_prefix, 'bin', binary_name)
if os.path.exists(python):
break
else:
self.fail(
'Couldn\'t find a python binary name under \'{}\' matching: {}'.format(
os.path.join(sys.real_prefix, 'bin'),
python_binary_names
)
)
# We're running off a virtualenv, and we don't want to create a virtualenv off of
# a virtualenv
kwargs = {'python': python}

View File

@ -87,7 +87,22 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
if salt.utils.is_windows():
python = os.path.join(sys.real_prefix, os.path.basename(sys.executable))
else:
python = os.path.join(sys.real_prefix, 'bin', os.path.basename(sys.executable))
python_binary_names = [
'python{}.{}'.format(*sys.version_info),
'python{}'.format(*sys.version_info),
'python'
]
for binary_name in python_binary_names:
python = os.path.join(sys.real_prefix, 'bin', binary_name)
if os.path.exists(python):
break
else:
self.fail(
'Couldn\'t find a python binary name under \'{}\' matching: {}'.format(
os.path.join(sys.real_prefix, 'bin'),
python_binary_names
)
)
# We're running off a virtualenv, and we don't want to create a virtualenv off of
# a virtualenv, let's point to the actual python that created the virtualenv
kwargs = {'python': python}