From 6a7ad9a2e4a083402a0656cd59f2029ff4c9ba91 Mon Sep 17 00:00:00 2001 From: heinezen Date: Fri, 23 Feb 2024 19:14:18 +0100 Subject: [PATCH 1/2] cli: Use CWD as DLL search path on Windows as default. --- openage/__main__.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/openage/__main__.py b/openage/__main__.py index a2bac73496..ac20017088 100644 --- a/openage/__main__.py +++ b/openage/__main__.py @@ -1,4 +1,4 @@ -# Copyright 2015-2023 the openage authors. See copying.md for legal info. +# Copyright 2015-2024 the openage authors. See copying.md for legal info. # # pylint: disable=too-many-statements """ @@ -44,12 +44,14 @@ def close_windows_dll_path_handles(dll_path_handles): for handle in dll_path_handles: handle.close() - if sys.platform == 'win32' and dll_paths is not None: - import atexit - win_dll_path_handles = [] - for addtional_path in dll_paths: - win_dll_path_handles.append(os.add_dll_directory(addtional_path)) - atexit.register(close_windows_dll_path_handles, win_dll_path_handles) + if sys.platform != 'win32' or dll_paths is None: + return + + import atexit + win_dll_path_handles = [] + for addtional_path in dll_paths: + win_dll_path_handles.append(os.add_dll_directory(addtional_path)) + atexit.register(close_windows_dll_path_handles, win_dll_path_handles) def main(argv=None): @@ -62,6 +64,7 @@ def main(argv=None): if sys.platform == 'win32': cli.add_argument( "--add-dll-search-path", action='append', dest='dll_paths', + default=[os.getcwd()], help="(Windows only) provide additional DLL search path") cli.add_argument("--version", "-V", action='store_true', dest='print_version', From 6e7a04390965098b19740a581b944fce9fbfbee6 Mon Sep 17 00:00:00 2001 From: heinezen Date: Sat, 24 Feb 2024 16:41:07 +0100 Subject: [PATCH 2/2] cli: Use entrypoint path as DLL search path on Windows as default. --- openage/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openage/__main__.py b/openage/__main__.py index ac20017088..c724d5bc6a 100644 --- a/openage/__main__.py +++ b/openage/__main__.py @@ -62,9 +62,11 @@ def main(argv=None): ) if sys.platform == 'win32': + import inspect cli.add_argument( "--add-dll-search-path", action='append', dest='dll_paths', - default=[os.getcwd()], + # use path of current openage executable as default + default=[os.path.dirname(os.path.abspath(inspect.getsourcefile(lambda: 0)))], help="(Windows only) provide additional DLL search path") cli.add_argument("--version", "-V", action='store_true', dest='print_version',