-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
22 lines (17 loc) · 867 Bytes
/
install.py
File metadata and controls
22 lines (17 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import subprocess
import sys
import os
import shutil
def install_requirements():
# Borrar la carpeta venv si ya existe
venv_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "venv")
if os.path.exists(venv_path):
shutil.rmtree(venv_path)
# Usar `py` con la versión específica de Python (en este caso, 3.10)
subprocess.run(["py", "-3.12", "-m", "venv", venv_path], check=True)
# Obtener la ruta al ejecutable de Python en el entorno virtual
venv_python = os.path.join(venv_path, "Scripts", "python.exe") if sys.platform == "win32" else os.path.join(venv_path, "bin", "python")
# Instalar dependencias desde requirements.txt usando el pip del entorno virtual
subprocess.run([venv_python, "-m", "pip", "install", "-r", "requirements.txt"], check=True)
if __name__ == "__main__":
install_requirements()