python / python/cpython

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

Offen
#101,500 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

topic-sysconfig type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
36k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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.

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 in Lib/sysconfig.py um Zeile 30 und reproduziere die gemeldeten Ergebnisse von sysconfig.get_path('stdlib') und get_path('platstdlib') in einer virtuellen Umgebung, im Python 3.11.1 Docker-Image und unter Fedora Linux. Als abgeschlossen gilt die Aufgabe, wenn der plattformspezifische Pfad zur Standardbibliothek in diesen Umgebungen mit der dokumentierten Unterscheidung übereinstimmt und eine Regressionstestabdeckung dort hinzugefügt wurde, wo die bestehende Testsuite sysconfig-Pfade behandelt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
tooling
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.