Skip to content

Commit 9941fc1

Browse files
committed
NEWS: add something for the add_dll_directory() change
and adjust the Python docs as well
1 parent 89f071f commit 9941fc1

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

web/docs/python.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ if os.name == "nt" and sysconfig.get_platform().startswith("mingw"):
2222
print("cpython-mingw detected!")
2323
```
2424

25+
Unlike many other Windows packages in MSYS2, Python will not look for DLL dependencies in PATH by default, but requires directories to be explicitly added via `os.add_dll_directory()` at runtime. You can disable this behavior, and make it look in PATH, by setting the `PYTHONLEGACYWINDOWSDLLLOADING` environment variable to `1`.
26+
2527
### Known issues
2628

2729
* C extensions are not compatible with the official CPython, which means pip can't use binary wheels from PyPI and packages have to be build when installing them.
2830
* Some C extensions don't build out of the box since they don't expect non-MSVC on Windows. In some cases we provide patched versions in our repo.
2931
* [setuptools](https://github.com/pypa/setuptools) >= 60.0 is currently incompatible with MSYS2. You can set `export SETUPTOOLS_USE_DISTUTILS=stdlib` to work around the issue. We are currently working on restoring compatibility.
30-
* It still looks up DLLs via PATH and `os.add_dll_directory()` doesn't work, see https://github.com/msys2-contrib/cpython-mingw/issues/48

web/news.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ summary: Important events happening.
55

66
This page lists important changes or issues affecting MSYS2 users. We also post them to [Twitter](https://twitter.com/msys2org) and [Mastodon](https://fosstodon.org/@msys2org), including some not-so-important things :)
77

8+
### 2023-08-06 - Python: Changed behavior when loading DLL dependencies of extension modules
9+
10+
Starting with CPython 3.8, upstream CPython changed their DLL lookup behavior to
11+
a safer default when loading extension modules, which meant no longer looking in
12+
PATH, but requiring code to explicitly add directories containing dependencies
13+
via
14+
[`os.add_dll_directory()`](https://docs.python.org/3/library/os.html#os.add_dll_directory).
15+
16+
Because many packages weren't ported yet back then, and this behavior interfered
17+
with our MinGW port build process we decided to revert this change and keep the
18+
old behavior. This had the downside that `os.add_dll_directory()` did not have
19+
any effect with our Python port and required different code paths for the
20+
official CPython and our one.
21+
22+
We have now switched the default to what the official CPython build does, but
23+
added a new `PYTHONLEGACYWINDOWSDLLLOADING` environment variable which you can
24+
set to `1` to get back the legacy behavior if needed.
25+
26+
If this change is causing problems for you:
27+
28+
* Make sure to use `os.add_dll_directory()`, as recommended by upstream, see
29+
https://docs.python.org/3/library/os.html#os.add_dll_directory for details
30+
* If that doesn't work you can use `export PYTHONLEGACYWINDOWSDLLLOADING=1` to
31+
revert to the old behavior. Please let us know why you need it, so we can
32+
hopefully adjust our build to handle more use cases by default.
33+
834
### 2023-04-01 - LLVM 16
935

1036
LLVM/Clang has now been updated to v16, here are some things to look out for:

0 commit comments

Comments
 (0)