-
Notifications
You must be signed in to change notification settings - Fork 0
/
erllm_setup.py
22 lines (20 loc) · 998 Bytes
/
erllm_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
Add .pth file to the site-packages directory of the current Python interpreter to make erllm discoverable.
"""
from pathlib import Path
import site
if __name__ == "__main__":
"""
Generates a .pth file with the absolute path to the parent folder of erllm and adds it to the site-packages directory of the current Python interpreter.
This makes erllm behave as if it were a installed third-party packages.
Yet it also supports code changes without reinstall.
"""
# Get the absolute path of the erllm folder
script_folder = Path(__file__).resolve().parent.parent
# Specify the content for the .pth file as the absolute path of the script's folder
pth_content = str(script_folder)
# Get the site-packages directory of the current interpreter
site_packages_dir = Path(site.getsitepackages()[0])
pth_file_path = site_packages_dir / "erllm.pth"
pth_file_path.write_text(pth_content)
print(f".pth file added to site-packages: {pth_file_path}")