Skip to content

sysconfig variable impermanence in virtual environment when cross-compiling #150162

Description

@hetmankp

Bug report

Bug description:

The solution to issue GH-126789 (found in GH-127729 / 7015485) 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-sysconfigtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions