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

Ouverte
#95,400 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

build OS-mac type-bug
Langage dominant
Python
Étoiles
77.2k
Forks
36k
Métriques de merge des PR
Métriques de PR en attente

Description

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
.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par reproduire les commandes d’exécution directe et de symlink externe sur macOS, en comparant l’importation réussie avec le cas où lib-dynload est manquant. Examinez ensuite le fichier joint relocated_framework.patch.gz ainsi que la gestion du démarrage et des chemins du framework qu’il modifie. Le travail est terminé lorsque l’importation de math fonctionne quand le framework déplacé est exécuté via le symlink externe.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
operating-systems
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.