SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.79k stars 1.13k forks source link

Enhance DLL search on Windows #1649

Closed heinezen closed 6 months ago

heinezen commented 6 months ago

Fixes the import errors for the compiled libraries and Python modules on Windows by adding better default search paths. If you build openage from source with the documented instructions, there shouldn't be any Python errors after this PR.

The problem in https://github.com/SFTtech/openage/issues/1644 was that the dependent libraries were no longer found automatically since Python 3.8 and you had to use --add-dll-search-path to avoid errors. However, it's not always obvious how this argument should be used. Therefore, openage now sets sane defaults to search for:

Furthermore, it fixes the errors in https://github.com/SFTtech/openage/issues/1624 . These happened because the DLLs are only set per process, so subprocesses in multiprocessing were not aware about the DLL search paths. This problem is now solved by adding a DllDirectoryManager object that can be passed around and then used to add/remove DLL search paths.

simonsan commented 6 months ago

Wow, what a clusterfuck, I remember when we discovered that. Didn't know it's still leaving its trail! Excellent idea with the DllManager, will probably make it much easier to react to Python's weirdness in that regard in the future. 👍🏽