mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix salt-api not starting and ensure the pip module installs into the desired relenv directory by default
This commit is contained in:
parent
55b2590cdb
commit
bb2a12db32
3 changed files with 20 additions and 17 deletions
|
@ -1,7 +1,9 @@
|
|||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
import yaml
|
||||
|
@ -457,10 +459,24 @@ def test_account(salt_call_cli):
|
|||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def salt_api(salt_master, install_salt):
|
||||
def extras_pypath():
|
||||
extras_dir = "extras-{}.{}".format(*sys.version_info)
|
||||
if platform.is_windows():
|
||||
return pathlib.Path(
|
||||
os.getenv("ProgramFiles"), "Salt Project", "Salt", extras_dir, "bin"
|
||||
)
|
||||
elif platform.is_darwin():
|
||||
return pathlib.Path(f"{os.sep}opt", "salt", extras_dir, "bin")
|
||||
else:
|
||||
return pathlib.Path(f"{os.sep}opt", "saltstack", "salt", extras_dir, "bin")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def salt_api(salt_master, install_salt, extras_pypath):
|
||||
"""
|
||||
start up and configure salt_api
|
||||
"""
|
||||
shutil.rmtree(str(extras_pypath.parent), ignore_errors=True)
|
||||
start_timeout = None
|
||||
if platform.is_windows() and install_salt.singlebin:
|
||||
start_timeout = 240
|
||||
|
|
|
@ -17,19 +17,6 @@ def pypath():
|
|||
return pathlib.Path(f"{os.sep}opt", "saltstack", "salt", "bin")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def extras_pypath():
|
||||
extras_dir = "extras-{}.{}".format(*sys.version_info)
|
||||
if platform.is_windows():
|
||||
return pathlib.Path(
|
||||
os.getenv("ProgramFiles"), "Salt Project", "Salt", extras_dir, "bin"
|
||||
)
|
||||
elif platform.is_darwin():
|
||||
return pathlib.Path(f"{os.sep}opt", "salt", extras_dir, "bin")
|
||||
else:
|
||||
return pathlib.Path(f"{os.sep}opt", "saltstack", "salt", extras_dir, "bin")
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def wipe_pydeps(install_salt):
|
||||
try:
|
||||
|
@ -37,7 +24,7 @@ def wipe_pydeps(install_salt):
|
|||
finally:
|
||||
# Note, uninstalling anything with an associated script will leave the script.
|
||||
# This is due to a bug in pip.
|
||||
for dep in ["pep8", "PyGithub", "libvirt-python"]:
|
||||
for dep in ["pep8", "PyGithub"]:
|
||||
subprocess.run(
|
||||
install_salt.binary_paths["pip"] + ["uninstall", "-y", dep],
|
||||
stdout=subprocess.PIPE,
|
||||
|
|
|
@ -144,7 +144,7 @@ def _check_bundled():
|
|||
"""
|
||||
Gather run-time information to indicate if we are running from source or bundled.
|
||||
"""
|
||||
if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"):
|
||||
if hasattr(sys, "RELENV"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -157,7 +157,7 @@ def _get_pip_bin(bin_env):
|
|||
if not bin_env:
|
||||
if _check_bundled():
|
||||
logger.debug("pip: Using pip from bundled app")
|
||||
return [os.path.normpath(sys.executable), "pip"]
|
||||
return [str(sys.RELENV / "salt-pip")]
|
||||
else:
|
||||
logger.debug("pip: Using pip from currently-running Python")
|
||||
return [os.path.normpath(sys.executable), "-m", "pip"]
|
||||
|
|
Loading…
Add table
Reference in a new issue