From c5669a292de3801ed1f330257d125a8dfeb996b1 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 14 Apr 2021 11:38:54 +0200 Subject: [PATCH] define `OPENPYPE_ROOT`variable at the top of start.py --- start.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/start.py b/start.py index a892d3de8e..67e65b35d2 100644 --- a/start.py +++ b/start.py @@ -100,10 +100,20 @@ import subprocess import site from pathlib import Path -# add dependencies folder to sys.pat for frozen code -if getattr(sys, 'frozen', False): +# OPENPYPE_ROOT is variable pointing to build (or code) directory +# WARNING `OPENPYPE_ROOT` must be defined before igniter import +# - igniter changes cwd which cause that filepath of this script won't lead +# to right directory +if not getattr(sys, 'frozen', False): + # Code root defined by `start.py` directory + OPENPYPE_ROOT = os.path.dirname(os.path.abspath(__file__)) +else: + OPENPYPE_ROOT = os.path.dirname(sys.executable) + + # add dependencies folder to sys.pat for frozen code frozen_libs = os.path.normpath( - os.path.join(os.path.dirname(sys.executable), "dependencies")) + os.path.join(OPENPYPE_ROOT, "dependencies") + ) sys.path.append(frozen_libs) # add stuff from `/dependencies` to PYTHONPATH. pythonpath = os.getenv("PYTHONPATH", "")