-
Notifications
You must be signed in to change notification settings - Fork 69
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
Building Windows wheels with libraries fails #525
Comments
I'm very surprised that you were able to build the wheel that published on PyPI for CapyPDF 0.5.0. As the error message says, bundling shared libraries into wheels is not supported on Windows, and never was. The reason is that meson-python needs to play tricks with RPATH to have the libraries loaded from the location where they are installed, and AFAIK Windows does not have the equivalent of an RPATH. Without setting the DLL load path, I don't know how The old wheel was build on September first. At that time meson-python 0.13.2 was the latest version. Can check that pinning the version of meson-python in |
I'll try that soon. But the way CapyPDF does it is that it does not build a Python extension, but instead a standalone shared library that it then opens with |
The way I would do this is to place the shared library next to the Python module and do not rely on the relocation of the shared library made by meson-python by adjusting the |
Using 0.13.2 works.
I tried this and it works but it is problematic. The CapyPDF library is meant to be usable also as a standard shared library so it needs to be installed to standard A better approach for this would be for Meson-Python to automatically tell it to install all libraries in the correct location. I tried setting |
This is interesting. We must have tightened the check along the way. Unfortunately, the existing check is correct in the general case, thus relaxing it again is not really an option. For example, the wheel for CapyPDF 0.5.0 includes a few executables that I'm fairly sure fail to load the required DLLs when executed on Windows.
Sure. I realize this is problematic, but the intersection of the limitations of the wheel package format and of Windows does not leave space for other solutions. At least I cannot come up with none that works in all use cases. The only thing I can think about is do the DLL relocation also on Windows and use a
The problem is that there is no "correct location" that works in the general case on Windows. On macOS and on Unix platforms we do just this and we adjust RPATH to make everything work. A possibility would be to add a setting to meson-python that says "I know what I am doing" and enables mapping SciPy uses delvewheel https://pypi.org/project/delvewheel/ to bundle DLLs in wheels on Windows. I haven't investigated how it works.
This is expected, meson-python needs to lock at the "unexpanded" definition of the install location to work correctly. |
Those executables should not be there and are never executed. They just get installed due to
This seems like a reasonable approach and is already how CapyPDF does it (it has heuristics to find out where the shared library is for every setup). In general having a way to install shared libs on Windows and it "just working" would be nice, but that probably requires assistance from Python upstream. |
I tried this on macOS. With meson-python 0.13.2, the result is an
Note the name is wrong, since the dylib is specific to macOS arm64 here - this will work for a local from-source install but not for distributing the wheel. It improves when adding
and that should work but doesn't produce the expected There's some logic to deal with locating the shared library in
which looks fragile, and indeed does not work for me without first doing:
Agreed that'd be quite nice. Python (packaging) upstream is unlikely to help us here though, we have to implement support for this ourselves. This issue is pretty much a duplicate of gh-265, where a potential solution direction is discussed. I've got more experience with that type of solution now that we're distribution OpenBLAS (shared/static libraries + pkg-config files and headers, no Python involved at all) inside a wheel. I think the pre-loading suggestion in gh-265 is doable. It basically matches the "I know what I'm doing" suggested solution direction in the comments above (with a bit more detail already). However, In order not to split the discussion, how about we continue the "shared library in wheel" part in gh-265, and close this issue? Plus open a new one for the |
This is a bug in meson-python. meson-python should have detected that the wheel contains platform specific components.
This is correct. The wheel does not contain Python ABi so it should not be marked with the
Not really a duplicate. CapyPDF does not distribute a Python extension module, so it does not need an equivalent for the RPATH handling to make the extension module find the shared libraries. |
This is an (obvious) oversight in meson-python. Fix in #526 |
Fair - partial duplicate at least though, since the place where the shared library ends up in the wheel needs to be exposed, and that's the critical part of the solution to enable the package author to then access that shared library directly (with |
I meant that I see these as two slightly different use cases: one is implementing a solution akin to the RPATH one on Windows, the other is simply having the shared libraries placed somewhere in the wheel. Having the shared library in a wheel consumed by another wheel maybe can be seen as another variation on the theme. |
Things get even weirder now. With CapyPDF 0.7.0 and meson-python 0.13.2 on Windows the I even tried adding a custom install script that deletes the exes but they still ended up in the final product. |
This was gh-423, and was fixed in 0.14.0
There is no longer a |
If you grab build targets from the build dir yourself the end result is not guaranteed to work. There may be e.g. remnants of RPATH in the binaries. If you don't do an actual install, the end result can break at any time for whatever reason. |
Not to mention that projects that need their post-install scripts to be run in order to work obviously won't work. |
Meson itself supports running build artifacts from the build directory via the |
These projects would indeed not be supported by meson-python, but no one has yet brought up an use case for this. |
That is because we use special platform dependenct magic to make that happen. It is only undone when doing an Also note that any target that uses
You can do that if you want, just be aware that if and when it breaks, you get to keep both pieces. In fact I suspect I have already hit this problem once. When I originally did the macOS extension it did not work due to some weird dylib lookup failure. I fixed it by building deps as static libs so that that only one dylib gets installed. |
Yup. meson-python needs to tweak RPATH too so we have very similar code.
I fixed several bugs in this area, thus if you tried that a while ago, I would be curious to know if you can still reproduce these issues. Unfortunately my macOS system is too old to compile CapyPDF. |
@jpakkane I would appreciate if you could give #551 a spin. You can do that setting
in Suggestions for a better name for the option are welcome. |
I tried it and it seems to be working. Thanks.
Maybe it should be something along the lines of |
|
When building a CapyPDF releases I now get the following error on Windows:
Ths is on 3.12.0, but I also tried downgrading to 3.11 and 3.10.11 (which used to work when I made the previous release AFAICR). Buildng the package on macOS 3.10.5 works without problems.
To reproduces:
meson.build
to change the default C++ version fromc++23
toc++latest
(no longer needed once the next Meson release comes out)pip3 install .
orpython -m build
The error message gives me zero relevant hits on Google.
The text was updated successfully, but these errors were encountered: