Skip to content

Commit 11b6f0e

Browse files
committed
Update build_install_menu.py
1 parent 1b3f884 commit 11b6f0e

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

automation_editor/automation_editor_ui/menu/install_menu/build_install_menu.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
import os
2+
import shutil
3+
import sys
4+
from pathlib import Path
5+
16
from PySide6.QtGui import QAction
27
from PySide6.QtWidgets import QMainWindow
8+
from je_editor import shell_manager
39

410

511
def set_install_menu(ui_we_want_to_set: QMainWindow):
@@ -36,26 +42,43 @@ def set_install_menu(ui_we_want_to_set: QMainWindow):
3642
ui_we_want_to_set.install_menu.addAction(ui_we_want_to_set.install_web_runner_action)
3743

3844

45+
def install_package(package_text: str):
46+
if sys.platform in ["win32", "cygwin", "msys"]:
47+
venv_path = Path(os.getcwd() + "/venv/Scripts")
48+
else:
49+
venv_path = Path(os.getcwd() + "/venv/bin")
50+
if venv_path.is_dir() and venv_path.exists():
51+
compiler_path = shutil.which(
52+
cmd="python3",
53+
path=str(venv_path)
54+
)
55+
else:
56+
compiler_path = shutil.which(cmd="python3")
57+
if compiler_path is None:
58+
compiler_path = shutil.which(
59+
cmd="python",
60+
path=str(venv_path)
61+
)
62+
else:
63+
compiler_path = shutil.which(cmd="python")
64+
shell_manager.exec_shell(f"{compiler_path} -m pip install {package_text}")
65+
66+
3967
def install_build_tools():
40-
from je_editor import shell_manager
41-
shell_manager.exec_shell("pip install --user --upgrade pip setuptools wheel")
68+
install_package("setuptools build wheel")
4269

4370

4471
def install_autocontrol():
45-
from je_editor import shell_manager
46-
shell_manager.exec_shell("pip install --user --upgrade je_auto_control")
72+
install_package("je_auto_control")
4773

4874

4975
def install_api_testka():
50-
from je_editor import shell_manager
51-
shell_manager.exec_shell("pip install --user --upgrade je_api_testka")
76+
install_package("je_api_testka")
5277

5378

5479
def install_load_density():
55-
from je_editor import shell_manager
56-
shell_manager.exec_shell("pip install --user --upgrade je_load_density")
80+
install_package("je_load_density")
5781

5882

5983
def install_web_runner():
60-
from je_editor import shell_manager
61-
shell_manager.exec_shell("pip install --user --upgrade je_web_runner")
84+
install_package("je_web_runner")

0 commit comments

Comments
 (0)