mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Make sys.path
cleanup work on windows
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
8b6497da72
commit
ba106493c5
1 changed files with 5 additions and 10 deletions
|
@ -2,19 +2,14 @@ import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
_repo_root = pathlib.Path(__file__).parent.parent
|
_repo_root = pathlib.Path(__file__).resolve().parent.parent
|
||||||
_paths_to_check = {""}
|
|
||||||
if sys.platform.startswith("win"):
|
|
||||||
_paths_to_check.add(str(_repo_root).replace("\\", "\\\\"))
|
|
||||||
_paths_to_check.add(str(_repo_root.resolve()).replace("\\", "\\\\"))
|
|
||||||
else:
|
|
||||||
_paths_to_check.add(str(_repo_root))
|
|
||||||
|
|
||||||
|
|
||||||
if os.environ.get("ONEDIR_TESTRUN", "0") == "1":
|
if os.environ.get("ONEDIR_TESTRUN", "0") == "1":
|
||||||
# In this particular case, we want to make sure that the repo root
|
# In this particular case, we want to make sure that the repo root
|
||||||
# is not part if sys.path so that when we import salt, we import salt from
|
# is not part if sys.path so that when we import salt, we import salt from
|
||||||
# the onedir and not the code checkout
|
# the onedir and not the code checkout
|
||||||
for path in _paths_to_check:
|
for path in list(sys.path):
|
||||||
if path in sys.path:
|
if path == "":
|
||||||
|
sys.path.remove(path)
|
||||||
|
elif pathlib.Path(path).resolve() == _repo_root:
|
||||||
sys.path.remove(path)
|
sys.path.remove(path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue