-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Description
This issue proposes addressing one aspect of Python's relocatability problem: enabling shared libraries to find their dependencies regardless of installation location. This is only the first step toward fully relocatable Python installations.
Background
Python packages require an interpreter, but CPython is difficult to distribute on non-Windows platforms because installations are not relocatable. When a CPython installation is built, the paths to required shared libraries are hardcoded, which means the installation cannot be moved to a different location without breaking.
Several community projects have attempted to solve this problem:
- [python-build-standalone](https://github.com/indygreg/python-build-standalone) by Gregory Szorc
- [PyOxidizer](https://github.com/indygreg/PyOxidizer)
- [relocatable-python](https://github.com/gregneagle/relocatable-python) for macOS
- Various approaches used by Anaconda to achieve relocatable builds
Non-relocatability causes several issues:
- Packaging tools like zipapp cannot fully distribute applications without depending on a pre-installed Python interpreter
- Users need different installation methods depending on their OS/distro
- Permission issues arise on macOS as noted in discussions
- Virtual environments and application distribution are more complex than necessary
We need a way for Python's binaries and shared libraries to locate their dependencies relative to their current location, rather than using absolute paths baked in at build time.
A viable approach is to utilize $ORIGIN
in RPATH settings for Linux binaries, which would allow shared libraries to be found relative to the binary's location.
This would address just one piece of the relocatability puzzle - ensuring that when Python is moved to a different location, the binaries can still find their shared library dependencies. This solves ONE specific problem: dynamic linking of shared libraries at runtime.
To be clear, this approach alone DOES NOT make Python fully relocatable - it's only the first building block.