From 473b9da5e95bb894ddc494603c05bd0af25e2e01 Mon Sep 17 00:00:00 2001
From: Lars Kruse <devel@sumpfralle.de>
Date: Sun, 13 Mar 2022 02:49:07 +0100
Subject: [PATCH] refactor: avoid manipulation of python's import path within
 the application

The environment should be configured outside of the application.
---
 run.sh     | 2 ++
 setup.py   | 2 --
 src/app.py | 3 ---
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/run.sh b/run.sh
index e08f904..349a237 100755
--- a/run.sh
+++ b/run.sh
@@ -34,12 +34,14 @@ echo "[ Docker=$docker ]"
 
 # Check for the correct Python version (3.8+)
 PYTHON_EXEC="python3"
+PYTHON_BASE_DIR="."
 echo "[ Using $("$PYTHON_EXEC" -V) ]"
 
 
 # +++ DEFAULT COMMANDS +++ #
 
 if [[ $docker == "false" ]]; then
+	export PYTHONPATH="$PYTHON_BASE_DIR"
 
 	### Runs the API Server (Development) ###
 
diff --git a/setup.py b/setup.py
index 412590f..bd80f62 100644
--- a/setup.py
+++ b/setup.py
@@ -17,8 +17,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-import sys
-
 from setuptools import find_packages, setup
 
 NAME = "engine-api"
diff --git a/src/app.py b/src/app.py
index fba8d53..954fb7e 100644
--- a/src/app.py
+++ b/src/app.py
@@ -18,11 +18,8 @@
 
 
 import atexit
-import os
 import sys
 
-sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
-
 import connexion
 
 import meta
-- 
GitLab