-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathun.py
27 lines (23 loc) · 878 Bytes
/
un.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import sys
import subprocess
# Get the path to the Python interpreter in the virtual environment
venv_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), ".venv")
python_path = os.path.join(venv_path, "Scripts", "python.exe")
# Install the package using the Python interpreter in the virtual environment
subprocess.run([python_path, "-m", "pip", "uninstall"] + sys.argv[1:])
# Update the requirements.txt file using the Python interpreter in the virtual environment
print("Updating requirements.txt...")
subprocess.run(
[python_path, "-m", "pip", "freeze"], stdout=subprocess.PIPE, text=True, check=True
)
with open("requirements.txt", "w", encoding="utf-8") as f:
f.write(
subprocess.run(
[python_path, "-m", "pip", "freeze"],
stdout=subprocess.PIPE,
text=True,
check=True,
).stdout
)
print("Successfully updated requirements.txt")