sysconfig.get_path('platstdlib') return paths in virtual environments (or otherwise weird)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Lib/sysconfig.py around line 30 and reproduce the reported sysconfig.get_path('stdlib') and get_path('platstdlib') results in a virtual environment, the Python 3.11.1 Docker image, and Fedora Linux. Done means the platform-specific standard-library path is consistent with the documented distinction across these environments, with regression coverage added where the existing test suite handles sysconfig paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100