sysconfig variable impermanence in virtual environment when cross-compiling
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
The solution to issue GH-126789 (found in GH-127729 / 70154855cf69) introduced a side effect when sysconfig variables are fetched in a virtual environment with the _PYTHON_PROJECT_BASE environment variable present (on posix platforms). Specifically, every invocation of sysconfig.get_config_vars() and sysconfig.get_config_var() causes the variable cache to be reset and rebuilt from scratch. This can be confirmed by running Python as follows:
virtualenv -p /usr/bin/python3.14 env # 3.14 or higher
_PYTHON_PROJECT_BASE=/any/path env/bin/python
And then executing:
import sysconfig
sysconfig.get_config_vars()['LIBDIR'] = '/some/new/path'
assert sysconfig.get_config_var('LIBDIR') != '/some/new/path'
Rebuilding the variable cache every time is fairly inefficient and prevents the possibility of tweaking the values (a sometimes necessary evil).
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-150164
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 with sysconfig.get_config_vars() and sysconfig.get_config_var() using the provided virtual-environment reproduction and _PYTHON_PROJECT_BASE setting. Trace why the cache is rebuilt on each call, add regression coverage, and verify that modified values persist across subsequent lookups.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100