Skip to content

Commit 5278bf2

Browse files
EvansCesilThomasamilcarlucas
authored andcommitted
fix(pip install): Change pip install command to use virtual environment
Fix for updating the software via the GUI update button Signed-off-by: Evans Cesil Thomas <148005352+EvansCesilThomas@users.noreply.github.com>
1 parent 2ddf606 commit 5278bf2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ardupilot_methodic_configurator/backend_internet.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import os
1212
import subprocess
13+
import sys
1314
import tempfile
1415
import time
1516
from datetime import datetime, timezone
@@ -238,7 +239,9 @@ def download_and_install_pip_release(progress_callback: Optional[Callable[[float
238239
if progress_callback:
239240
progress_callback(0.0, _("Starting installation..."))
240241

241-
ret = os.system("pip install --upgrade ardupilot_methodic_configurator") # noqa: S605, S607
242+
ret = subprocess.check_call( # noqa: S603
243+
[sys.executable, "-m", "pip", "install", "--upgrade", "ardupilot_methodic_configurator"]
244+
)
242245

243246
if ret == 0 and progress_callback:
244247
progress_callback(100.0, _("Download complete"))

tests/test_backend_internet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ def test_download_and_install_windows_download_failure(mock_download) -> None:
192192
assert not download_and_install_on_windows("http://test.com", "test.exe")
193193

194194

195-
@patch("os.system")
196-
def test_download_and_install_pip_release(mock_system) -> None:
197-
mock_system.return_value = 0
195+
@patch("subprocess.check_call")
196+
def test_download_and_install_pip_release(mock_check_call) -> None:
197+
mock_check_call.return_value = 0
198198
assert download_and_install_pip_release() == 0
199199

200200

0 commit comments

Comments
 (0)