Re-enable tiamat-pip on windows

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-02-07 12:41:59 +00:00 committed by Gareth J. Greenaway
parent b398065003
commit 76efef6e86

59
run.py
View file

@ -9,13 +9,9 @@ import sys
import salt.scripts
import salt.utils.platform
# tiamat pip breaks singlebin on Windows at the moment
# https://gitlab.com/saltstack/pop/tiamat-pip/-/issues/4
if not sys.platform.startswith("win"):
import tiamatpip.cli
import tiamatpip.configure
import tiamatpip.utils
import tiamatpip.cli
import tiamatpip.configure
import tiamatpip.utils
AVAIL = (
"minion",
@ -37,13 +33,25 @@ AVAIL = (
)
# tiamat pip breaks singlebin on Windows at the moment
# https://gitlab.com/saltstack/pop/tiamat-pip/-/issues/4
if not sys.platform.startswith("win"):
PIP_PATH = pathlib.Path(f"{os.sep}opt", "saltstack", "salt", "pypath")
with contextlib.suppress(PermissionError):
PIP_PATH.mkdir(mode=0o755, parents=True, exist_ok=True)
tiamatpip.configure.set_user_base_path(PIP_PATH)
else:
PIP_PATH = pathlib.Path(os.getenv("LocalAppData"), "salt", "pypath")
with contextlib.suppress(PermissionError):
PIP_PATH.mkdir(mode=0o755, parents=True, exist_ok=True)
tiamatpip.configure.set_user_base_path(PIP_PATH)
def py_shell():
if not sys.platform.startswith("win"):
# optional, will allow Up/Down/History in the console
import readline
import code
variables = globals().copy()
variables.update(locals())
shell = code.InteractiveConsole(variables)
shell.interact()
def redirect(argv):
@ -60,12 +68,9 @@ def redirect(argv):
if cmd == "shell":
py_shell()
return
# tiamat pip breaks singlebin on Windows at the moment
# https://gitlab.com/saltstack/pop/tiamat-pip/-/issues/4
if not sys.platform.startswith("win"):
if tiamatpip.cli.should_redirect_argv(argv):
tiamatpip.cli.process_pip_argv(argv)
return
if tiamatpip.cli.should_redirect_argv(argv):
tiamatpip.cli.process_pip_argv(argv)
return
if cmd not in AVAIL:
# Fall back to the salt command
args = ["salt"]
@ -75,26 +80,10 @@ def redirect(argv):
sys.argv.pop(1)
s_fun = getattr(salt.scripts, f"salt_{cmd}")
args.extend(argv[1:])
# tiamat pip breaks singlebin on Windows at the moment
# https://gitlab.com/saltstack/pop/tiamat-pip/-/issues/4
if not sys.platform.startswith("win"):
with tiamatpip.utils.patched_sys_argv(args):
s_fun()
else:
with tiamatpip.utils.patched_sys_argv(args):
s_fun()
def py_shell():
if not sys.platform.startswith("win"):
import readline # optional, will allow Up/Down/History in the console
import code
variables = globals().copy()
variables.update(locals())
shell = code.InteractiveConsole(variables)
shell.interact()
if __name__ == "__main__":
if sys.platform.startswith("win"):
multiprocessing.freeze_support()