Skip to content

Commit fd20e6c

Browse files
correct docker-compose pathing in executable
1 parent 7a2ae65 commit fd20e6c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

app.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ def start_project(self, exercise_name: str) -> None:
104104

105105
def run_tests(self, exercise_name: str) -> None:
106106
"""Run tests for the selected exercise and display the output."""
107-
log("starting to test")
108107
test_output = self.query_one("#test_output", TextArea)
109-
log("found test_output")
110-
command = f"docker-compose -f exercises_test_suites/docker_compose_{exercise_name}.yml up --build"
108+
docker_compose_file_name = ExercisesUtils.get_resource_path(f"exercises_test_suites/docker_compose_{exercise_name}.yml")
109+
command = f"docker-compose -f {docker_compose_file_name} up --build"
111110
try:
112111
test_output.notify("Tests execution started, might take a few seconds", timeout=3)
113112
result = subprocess.run(command, shell=True, capture_output=True, text=True, check=True)

exercises_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import platform
33
import subprocess
4+
import sys
45
from pathlib import Path
56

67
EXERCISES_DIR = Path(__file__).parent / "exercises"
@@ -25,3 +26,14 @@ def open_file_in_explorer(file_path):
2526
subprocess.run(["open", file_path])
2627
else: # Linux and other Unix-like systems
2728
subprocess.run(["xdg-open", file_path])
29+
30+
@staticmethod
31+
def get_resource_path(relative_path):
32+
""" Get the absolute path to the resource, accounting for PyInstaller packaging. """
33+
try:
34+
# PyInstaller creates a temporary folder and stores path in _MEIPASS
35+
base_path = sys._MEIPASS
36+
except AttributeError:
37+
base_path = os.path.abspath(".")
38+
39+
return os.path.join(base_path, relative_path)

0 commit comments

Comments
 (0)