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

[pyverbs] Don't link Python's .so at pyverbs module link stage #1565

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heiner
Copy link
Contributor

@heiner heiner commented Feb 21, 2025

The recommended way is to not link Python's .so during module linking. The symbols will be present at runtime because the dlopen happens from Python.

Cf. pypa/cibuildwheel#639 (comment) on why FIND_PACKAGE(Python 3 ... Development) doesn't work in the manylinux images.

This is one step towards hosting a compiled version of pyverbs on PyPI (the Python Package Index). (Right now, I maintain a source distribution, which recompiles pyverbs and all of ibverbs on pip install pyverbs.)

The recommended way is to not link python's .so during module linking.
The symbols will be present at runtime because the dlopen happens
from Python.

Cf. pypa/cibuildwheel#639 (comment)

Signed-off-by: Heiner <[email protected]>
@jgunthorpe
Copy link
Member

I don't know about recommended, IIRC not linking is against Debian policy. There are many linker features like symbol versions that simply do not work without linking it..

Why does your environment have a problem with this? Does it not use libpython?

@heiner
Copy link
Contributor Author

heiner commented Feb 21, 2025

Thanks for the quick turnaround time!

The context is my attempt to build pyverbs in the manylinux image. Python modules built there are meant to be broadly compatible with most Linux distributions out there. A Python module built in a manylinux image could be uploaded to PyPI and installed via simply downloading a binary (instead of recompiling during installation).

One attempt to build pyverbs in this environment is in this branch: https://github.com/heiner/pyverbs/tree/heiner/cibuildwheel (relevant files are https://github.com/heiner/pyverbs/blob/heiner/cibuildwheel/pyproject.toml and https://github.com/heiner/pyverbs/blob/heiner/cibuildwheel/.github/workflows/publish.yml)

The first issue this runs into is that in the manylinux_2_28 image FIND_PACKAGE(Python 3 ... Development) does not work since Development means both Development.Module and Development.Embed and the latter isn't available there; as per the comment linked above Development.Embed is intentionally deleted to save space and stop a common mistake. The PR here fixes that. (Cf. also this SO answer and the second warning in the pybind11 docs here.)

I'm unsure about the Debian policy, do you happen to have a reference for that? If that's preferable, pyverbs could enable linking to the Python .so based on a cmake flag?

Alternatively, I could abandon the attempt to make pip install pyverbs work with pre-compiled binaries. The change in this PR is not sufficient for that at any rate, additional changes are required for pyverbs to link against a system-installed version of ibverbs (or shipping all ibverbs .so files together with the precompiled wheel).

@heiner
Copy link
Contributor Author

heiner commented Feb 21, 2025

This recommendation for the Python ecosystem is made in PEP 513:

Note that libpythonX.Y.so.1 is not on the list of libraries that a manylinux1 extension is allowed to link to.

@jgunthorpe
Copy link
Member

If this isn't enough to achieve your goal I would prefer not to change it. I know there are distro sensitives to this topic. Come with a series that does everything you need and makes this optional only for manylinux.

@heiner
Copy link
Contributor Author

heiner commented Feb 24, 2025

SG!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants