Skip to content
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

ENH: support shared libraries inside packages #257

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rgommers
Copy link
Contributor

@rgommers rgommers commented Dec 5, 2024

This drops the use of staged installs with --destdir in favor of using --prefix for the install location. The problem is that RPATHs in extension modules end up pointing to what Meson thinks is the final install location (i.e., inside the prefix) rather than to the staging directory.

--destdir seems meant for packaging, as an actual staging area, while for spin the final install directory is build-install (by default), there is no intent to later put this package into /usr or C:\. Hence using --prefix seems like the correct thing to do.

The one test change here is to a test that was incorrect. meson setup --prefix expects an absolute path, and /foobar isn't a path that exists or can be created.

Addresses the issue discussed in gh-238 - the spin build behavior before this change cannot be made to work for SciPy, because the internal shared library in scipy.special keeps breaking. It should also address the problem discussed in issue gh-176.

It may be my fault for suggesting the use of --destdir early on in spin's life - I think I understand the tradeoffs a bit better now.

@stefanv question about testing - do you want me to extend example_pkg with a shared library? It will look like sharedlib-in-package/mypkg/sub/* in mesonbuild/meson-python#700. It's a little bit of extra complexity, but it should be pretty robust since it mirrors what SciPy has internally.

Copy link
Contributor

@czgdp1807 czgdp1807 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is exactly what we need. I think it is a non-breaking change. I did this change in #238 and it worked with NumPy as well.

May be we can accept ––destdir as an optional argument and pass it only when available. That way if someone needs it they can pass it via spin build ––destdir. In simple words, its just like what we did for ––prefix in spin.

@rgommers
Copy link
Contributor Author

rgommers commented Dec 5, 2024

May be we can accept ––destdir as an optional argument and pass it only when available. That way if someone needs it they can pass it via spin build ––destdir.

I don't think anyone needs it - I'd avoid adding it unless there's a real-world use case. spin by design I think has one install directory per build directory, and that is it.

@stefanv
Copy link
Member

stefanv commented Dec 5, 2024

Good catch, thanks @rgommers! Happy to move to --prefix, I don't think that will negatively impact any other project. And, yes, no problem adding a minimally viable shared library to example_pkg.

@stefanv stefanv added the type: Bug fix Something isn't working label Dec 5, 2024
This drops the use of staged installs with `--destdir` in favor
of using `--prefix` for the install location. The problem is that
RPATHs in extension modules end up pointing to what Meson thinks is
the final install location (i.e., inside the prefix) rather than
to the staging directory.

`--destdir` seems meant for packaging, as an actual staging area,
while for `spin` the final install directory is `build-install`
(by default), there is no intent to later put this package into
`/usr` or `C:\`. Hence using `--prefix` seems like the correct
thing to do.

The one test change here is to a test that was incorrect.
`meson setup --prefix` expects an absolute path, and `/foobar`
isn't a path that exists or can be created.

Addresses the issue discussed in PR 238 - the `spin build` behavior
before this change cannot be made to work for SciPy, because the
internal shared library in `scipy.special` keeps breaking.

It should also address the problem discussed in issue spin#176.
@rgommers rgommers force-pushed the fix-sharedlibs branch 3 times, most recently from dd3c945 to 8620c27 Compare December 5, 2024 20:33
This tests using a shared library from a Python extension module,
which is relevant for SciPy (scipy.special contains such a shared
library).
@rgommers
Copy link
Contributor Author

rgommers commented Dec 5, 2024

I can't quite tell what's up with the editable install failures on Windows. Will need to switch to a Windows machine to see what's up - could be something trivial, but if it's not then it's probably relevant for SciPy as well when we switch to spin.

@stefanv
Copy link
Member

stefanv commented Dec 5, 2024

Windows is very finicky; I have a test machine here for that purpose, and can help debug if that'd be helpful.

@rgommers
Copy link
Contributor Author

rgommers commented Dec 8, 2024

Windows is very finicky; I have a test machine here for that purpose, and can help debug if that'd be helpful.

Thanks. I'll try to have a look at it in the coming days, but if you have time to look at it that may be helpful. I haven't quite followed along with how editable install support in spin works.

@stefanv
Copy link
Member

stefanv commented Dec 9, 2024

ImportError: DLL load failed while importing _core: The specified module could not be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: Bug fix Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants