python / python/cpython

sysconfig.get_path('platstdlib') return paths in virtual environments (or otherwise weird)

Ouverte
#101,500 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

topic-sysconfig 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

The sysconfig.get_path function is supposed to return he following for its first argument:

  • stdlib: directory containing the standard Python library files that are not platform-specific.
  • platstdlib: directory containing the standard Python library files that are platform-specific.

E.g. in the python:3.11.1 Docker container:

>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/local/lib/python3.11'
>>> sysconfig.get_path('platstdlib')
'/usr/local/lib/python3.11'

Or on a Python build configured with lib64 platlibdir (e.g. on Fedora Linux with $RPM_BUILD_ROOT environment variable set):

>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/lib64/python3.11'
>>> sysconfig.get_path('platstdlib')
'/usr/lib64/python3.11'

Yet in virtual environments, the platstdlib directory returns a directory from within the virtual environment. E.g. in the python:3.11.1 Docker container:

>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/local/lib/python3.11'
>>> sysconfig.get_path('platstdlib')
'.../myvenv/lib/python3.11'

Or on Fedora Linux:

>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/lib64/python3.11'
>>> sysconfig.get_path('platstdlib')
'.../myvenv/lib64/python3.11'

This even confuses the default values on Fedora Linux (without $RPM_BUILD_ROOT environment variable set):

>>> import sysconfig
>>> sysconfig.get_path('stdlib')
'/usr/lib64/python3.11'
>>> sysconfig.get_path('platstdlib')
'/usr/local/lib64/python3.11'

I believe that here:

https://github.com/python/cpython/blob/62251c3da06eb4662502295697f39730565b1717/Lib/sysconfig.py#L30

The {platbase} variable should be replaced with {insatlled_base} or even (currently AFAIK nonexistent) {insatlled_platbase}.

Your environment

  • CPython versions tested on: 3.11.1
  • Operating system and architecture: Fedora Linux 37 x86_64, python:3.11.1 Docker container.

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 dans Lib/sysconfig.py, autour de la ligne 30, et reproduisez les résultats signalés de sysconfig.get_path('stdlib') et get_path('platstdlib') dans un environnement virtuel, dans l’image Docker Python 3.11.1 et sous Fedora Linux. Le travail est terminé lorsque le chemin de la bibliothèque standard spécifique à la plateforme est cohérent avec la distinction documentée dans ces environnements, et qu’une couverture de régression a été ajoutée là où la suite de tests existante traite les chemins sysconfig.

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

Évaluation

Stack technique
python
Domaine
tooling
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.