From 4098a29c8e6d75552de482ee7c9e72131ed9e8d1 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 11 Apr 2024 16:51:42 +0100 Subject: [PATCH] Add windows support to `_verify_virtualenv` function in `salt.modules.virtualenv_mod` --- salt/modules/virtualenv_mod.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/salt/modules/virtualenv_mod.py b/salt/modules/virtualenv_mod.py index 36fd6c9d93d..042847fde40 100644 --- a/salt/modules/virtualenv_mod.py +++ b/salt/modules/virtualenv_mod.py @@ -501,11 +501,13 @@ def _verify_safe_py_code(*args): def _verify_virtualenv(venv_path): - bin_path = os.path.join(venv_path, "bin/python") + if salt.utils.platform.is_windows(): + bin_path = os.path.join(venv_path, "Scripts", "python.exe") + else: + bin_path = os.path.join(venv_path, "bin", "python") + if not os.path.exists(bin_path): raise CommandExecutionError( - "Path '{}' does not appear to be a virtualenv: bin/python not found.".format( - venv_path - ) + f"Path '{venv_path}' does not appear to be a virtualenv: '{bin_path}' not found." ) return bin_path