-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linking against libraries from meson on Windows #265
Comments
Assuming you mean shared libraries that are built within the project that |
Thanks for detailed explanation.
Then |
It fixes the issue, but that's way too much of a restriction. Your average Python package will have multiple directories, and it can have extensions in each one of them. The RUNPATH solution for non-Windows platforms works no matter where you put your extension modules. For Windows we can achieve the same probably, but it needs some preloading solution and it's going to be uglier than using RUNPATH. Or maybe a shim dll per shared library that you want to ship:
|
I understand your concerns. We need to make DLLs in |
The issue is that AFAIK there's no way to do this without custom code on Windows. To install the libraries inside the module, I think you can pass
We could consider a solution similar than what we are doing for editable installs. But IMO this should be something provided by either Python, or the packaging ecosystem already. |
I would not expect anyone in Python packaging land to care, except scikit-build which will have the same type of user profile and demand for non-Python shared library support. So I think if we coordinate with them, that should suffice.
I think that will work in principle, for Python >= 3.8 (which is enough for this feature). See the notes in https://github.com/MacPython/scipy-wheels/blob/054a522e893f489cd5ccb206f620c51395b09649/_distributor_init.py#L28-L59. However, modifying a user's if os.name == 'nt': # note: add clause for sys.version >= 3.8 if project still support py37
mesonpy_dlldir = `../.pkgname.mesonpy.libs` # fixme: use portable path specification here
if os.exists(mesonpy_dlldir): # directory may not exist, if we're building with `meson` directly
os.add_dll_directory(mesonpy_dlldir) That should be simple enough to not get wrong, and this only affects a small amount of users so I'd be happy enough with a doc-only solution here. It only leaves out the case of no Python package but a standalone Python extension module which depends on a DLL, but in that case the user can do what @FFY00 suggests above and install both files to the same directory. That can be documented as well. |
The doc-only solution is OK, and meson-python should output warnings about this on Windows if DLLs are packaged. |
One more note on this: on Python 3.8 installed with Conda there may still be problems with |
One alternative solution I just thought of is to ad a setting to allow running I believe this may work for most "build on Windows from source with a shared library" needs. The exception being if you are trying to ship a shared library in a wheel for consumption outside of that package (because the symbol mangling applied by So a complete solution may be:
|
We need to modify the rpath of shared library on Linux and Mac, but there is no corresponding mechanism on Windows.
Are there any blockers preventing us from copying DLLs into wheels on Windows directly?
The text was updated successfully, but these errors were encountered: