-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_python_path.py
More file actions
23 lines (18 loc) · 895 Bytes
/
set_python_path.py
File metadata and controls
23 lines (18 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
from pathlib import Path
current_directory = Path(__file__).parent
job_monitoring_app_directory = current_directory / "job_monitoring_app"
trackerapi_directory = job_monitoring_app_directory / "trackerapi" / "trackerapi"
# List of directories that contain your modules
directories = [job_monitoring_app_directory, trackerapi_directory, current_directory]
# Get the current PYTHONPATH
python_path = os.environ.get("PYTHONPATH", "").split(os.pathsep)
print("Current PYTHONPATH:", python_path)
# Add your directories to the PYTHONPATH if they are not already there
for directory in directories:
if directory not in python_path:
python_path.append(directory.as_posix())
# Update the PYTHONPATH environment variable
os.environ["PYTHONPATH"] = os.pathsep.join(python_path)
# Verify that the directories have been added
print("Updated PYTHONPATH:", os.environ["PYTHONPATH"])