python / python/cpython

Running Python from the build directory can lead to wrong `libpython` being loaded

Open
#128,469 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Proposal:

Right now, since we don't set RPATH, when using a shared libpython and running Python from the build directory, the library might resolve to the system, instead of the local one.

If possible, it would be good to set RPATH on the Python binary in the build directory, to force the local libpython library to be loaded. It would also be preferred to use RPATH instead of RUNPATH, as the prior has precedence over LD_LIBRARY_PATH, which users might have set.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs
  • gh-128470
  • gh-128645
  • gh-129506

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the linked pull requests gh-128470, gh-128645, and gh-129506 first, since they cover the proposed build-directory loading change. Verify that running Python from the build directory loads the local shared libpython and that RPATH is used instead of RUNPATH where supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.