Skip to content

Commit

Permalink
Merge pull request #1628 from heinezen/fix/dll_search_path
Browse files Browse the repository at this point in the history
Always use CWD as DLL search path on Windows
  • Loading branch information
TheJJ authored Feb 25, 2024
2 parents 781e731 + 6e7a043 commit 2f1ea21
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions openage/__main__.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand Down Expand Up @@ -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):
Expand All @@ -60,8 +62,11 @@ def main(argv=None):
)

if sys.platform == 'win32':
import inspect
cli.add_argument(
"--add-dll-search-path", action='append', dest='dll_paths',
# 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',
Expand Down

0 comments on commit 2f1ea21

Please sign in to comment.