python / python/cpython

macOS built Python3.11b5 can't find lib-dynload in relocatable framework if framework is relocated and python run from external symlink

Aperta
#95,400 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

build OS-mac type-bug
Lingua principale
Python
Stelle
77.2k
Fork
36k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug report

A build of Python 3.11b5's fails to find lib-dynload path if the following normally ok combination of criteria are met:

  • The framework is made or modified in such a away to be relocatable (dynamic links are relative using @loader_path, etc) instead of absolute path
  • The framework is installed in a location it wasn't built at
  • python is executed by a symlink from elsewhere

Your environment

To reproduce this easily, I decompressed the installable package into my home directory, making a framework structure that would normally run. I do have to modify the linking to work relocated, using the following commands:

 install_name_tool -change /Library/Frameworks/Python.framework/Versions/3.11/Python @loader_path/../Python Python.framework/Versions/3.11/bin/python3.11
 install_name_tool -change /Library/Frameworks/Python.framework/Versions/3.11/Python @loader_path/../../../../Python Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python

I then symlink the python executable.

ln -s Python.framework/Versions/3.11/bin/python3.11 python3.11

the following command works fine

./Python.framework/Versions/3.11/bin/python3.11 -c "import math"

while this does not

 ./python3.11 -c "import math"
Could not find platform dependent libraries <exec_prefix>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'math'

even though the shell itself works normally, just the lib-dynload is not being found.

I can make it work with the attached patch, but I don't assume it is the correct way to fix it
relocated_framework.patch.gz
.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo i comandi di esecuzione diretta e symlink esterno su macOS, confrontando l’importazione riuscita con il caso in cui manca lib-dynload. Poi esamina il file allegato relocated_framework.patch.gz e la gestione dell’avvio e dei percorsi del framework che modifica. Il lavoro è completato quando l’importazione di math funziona eseguendo il framework ricollocato tramite il symlink esterno.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
operating-systems
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.