mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
add Path to determine system executable and add edge case
This commit is contained in:
parent
158762bd5e
commit
f6c35856c9
1 changed files with 11 additions and 4 deletions
|
@ -86,6 +86,7 @@ import re
|
|||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
import pkg_resources # pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
|
@ -150,13 +151,19 @@ def _get_pip_bin(bin_env):
|
|||
executable itself, or from searching conventional filesystem locations
|
||||
"""
|
||||
if not bin_env:
|
||||
if "run" in os.path.normpath(sys.executable):
|
||||
logger.debug("pip: Using pip from run executable")
|
||||
return [os.path.normpath(sys.executable), "pip"]
|
||||
else:
|
||||
path = Path(sys.executable)
|
||||
if path.name == "python":
|
||||
logger.debug("pip: Using pip from currently-running Python")
|
||||
return [os.path.normpath(sys.executable), "-m", "pip"]
|
||||
|
||||
elif path.name != "python" or path.name == "run" or path.name == "pip":
|
||||
logger.debug("pip: Using pip binary or from unknown executable")
|
||||
return [os.path.normpath(sys.executable), "pip"]
|
||||
|
||||
else:
|
||||
logger.debug("System executable is None")
|
||||
return False
|
||||
|
||||
python_bin = "python.exe" if salt.utils.platform.is_windows() else "python"
|
||||
|
||||
def _search_paths(*basedirs):
|
||||
|
|
Loading…
Add table
Reference in a new issue