2022-12-22 08:31:23 +00:00
|
|
|
import os
|
|
|
|
import pathlib
|
|
|
|
import sys
|
|
|
|
|
|
|
|
_repo_root = pathlib.Path(__file__).parent.parent
|
2023-02-20 17:48:01 +00:00
|
|
|
_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))
|
|
|
|
|
2022-12-22 08:31:23 +00:00
|
|
|
|
2023-01-23 11:47:03 +00:00
|
|
|
if os.environ.get("ONEDIR_TESTRUN", "0") == "1":
|
2022-12-22 08:31:23 +00:00
|
|
|
# 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
|
|
|
|
# the onedir and not the code checkout
|
2023-02-20 17:48:01 +00:00
|
|
|
for path in _paths_to_check:
|
|
|
|
if path in sys.path:
|
|
|
|
sys.path.remove(path)
|