1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

EDMarketConnector.py: Move chdir as early as possible

We need the config.py read of .gitversion to be from the right place.
This commit is contained in:
Athanasius 2021-04-02 18:39:58 +01:00
parent 7bbc8e86a2
commit 103e856446

View File

@ -16,6 +16,17 @@ from sys import platform
from time import localtime, strftime, time from time import localtime, strftime, time
from typing import TYPE_CHECKING, Any, Mapping, Optional, Tuple from typing import TYPE_CHECKING, Any, Mapping, Optional, Tuple
# Have this as early as possible for people running EDMarketConnector.exe
# from cmd.exe or a bat file or similar. Else they might not be in the correct
# place for things like config.py reading .gitversion
if getattr(sys, 'frozen', False):
# Under py2exe sys.path[0] is the executable name
if platform == 'win32':
chdir(dirname(sys.path[0]))
# Allow executable to be invoked from any cwd
environ['TCL_LIBRARY'] = join(dirname(sys.path[0]), 'lib', 'tcl')
environ['TK_LIBRARY'] = join(dirname(sys.path[0]), 'lib', 'tk')
from constants import applongname, appname, protocolhandler_redirect from constants import applongname, appname, protocolhandler_redirect
# config will now cause an appname logger to be set up, so we need the # config will now cause an appname logger to be set up, so we need the
@ -236,14 +247,6 @@ if TYPE_CHECKING:
"""Fake the l10n translation functions for typing.""" """Fake the l10n translation functions for typing."""
return x return x
if getattr(sys, 'frozen', False):
# Under py2exe sys.path[0] is the executable name
if platform == 'win32':
chdir(dirname(sys.path[0]))
# Allow executable to be invoked from any cwd
environ['TCL_LIBRARY'] = join(dirname(sys.path[0]), 'lib', 'tcl')
environ['TK_LIBRARY'] = join(dirname(sys.path[0]), 'lib', 'tk')
import tkinter as tk import tkinter as tk
import tkinter.filedialog import tkinter.filedialog
import tkinter.font import tkinter.font