Differently from many, I implemented this fix using a context manager that automatically closes the dll cookies. Since this functionality is necessary to properly import SWIG bindings in the affected platform (I suspect that also pybind11 is affected), I added the context manager to cmake-build-extension so that it can be used downstream. The only change is that, if the context manager is used e.g. in the __init__.py file, the downstream package has to mark cmake-build-extension as install_require and no longer as only setup_require (or, in a more modern setup, in the requires field of pyproject.toml).
from cmake_build_extension import build_extension_env
with build_extension_env():
# Assuming that 'bindings' is the name of the SWIG / pybind11 module
from . import bindings
Related resources from which this PR was inspired:
Fixes #8
Apparently the problem is not a bug but a change of behavior in Windows. Refer to
add_dll_directory
for more details.Differently from many, I implemented this fix using a context manager that automatically closes the dll cookies. Since this functionality is necessary to properly import SWIG bindings in the affected platform (I suspect that also pybind11 is affected), I added the context manager to
cmake-build-extension
so that it can be used downstream. The only change is that, if the context manager is used e.g. in the__init__.py
file, the downstream package has to markcmake-build-extension
asinstall_require
and no longer as onlysetup_require
(or, in a more modern setup, in therequires
field of pyproject.toml).Related resources from which this PR was inspired: