Skip to content

Add support for relocatable installations using $ORIGIN in RPAT #131780

@pablogsal

Description

@pablogsal

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:

Non-relocatability causes several issues:

  1. Packaging tools like zipapp cannot fully distribute applications without depending on a pre-installed Python interpreter
  2. Users need different installation methods depending on their OS/distro
  3. Permission issues arise on macOS as noted in discussions
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions