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

Offen
#95,400 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

build OS-mac type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
36k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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
.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die Befehle für direkte Ausführung und externe Symlinks unter macOS nachzustellen und den erfolgreichen Import mit dem Fall des fehlenden lib-dynload zu vergleichen. Untersuche anschließend die angehängte relocated_framework.patch.gz und die Framework-Start-/Pfadbehandlung, die sie ändert. Als abgeschlossen gilt es, wenn der Import von math funktioniert, wenn das verschobene Framework über den externen Symlink ausgeführt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
operating-systems
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.