|
| 1 | +import os |
| 2 | +import shutil |
| 3 | +import sys |
| 4 | +from pathlib import Path |
| 5 | + |
1 | 6 | from PySide6.QtGui import QAction |
2 | 7 | from PySide6.QtWidgets import QMainWindow |
| 8 | +from je_editor import shell_manager |
3 | 9 |
|
4 | 10 |
|
5 | 11 | def set_install_menu(ui_we_want_to_set: QMainWindow): |
@@ -36,26 +42,43 @@ def set_install_menu(ui_we_want_to_set: QMainWindow): |
36 | 42 | ui_we_want_to_set.install_menu.addAction(ui_we_want_to_set.install_web_runner_action) |
37 | 43 |
|
38 | 44 |
|
| 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 | + |
39 | 67 | 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") |
42 | 69 |
|
43 | 70 |
|
44 | 71 | 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") |
47 | 73 |
|
48 | 74 |
|
49 | 75 | 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") |
52 | 77 |
|
53 | 78 |
|
54 | 79 | 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") |
57 | 81 |
|
58 | 82 |
|
59 | 83 | 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