Skip to content

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

Open
@hroncok

Description

@hroncok

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:

'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}',

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions