Skip to content

Commit

Permalink
cli: Use CWD as DLL search path on Windows as default.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Feb 23, 2024
1 parent 781e731 commit 6a7ad9a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 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 @@ -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',
Expand Down

0 comments on commit 6a7ad9a

Please sign in to comment.