Skip to content

Rewrite sysconfig.get_config_vars data generation to receive clearly-defined inputs #128072

Open
@FFY00

Description

@FFY00

Feature or enhancement

Proposal:

Right now, some of the data is calculated during import, then we use that to calculate more data when building the sysconfig.get_config_vars cache. It would be good to transform all of this into a clearly defined algorithm, where we the data is generated based on a set of inputs, making it easier to generate data when cross-compiling, and allowing us to generate data for a specific environment (eg. source builds, vs installed build). This would have helped mitigate issues such as GH-127429, GH-128055, and GH-126789.

Additionally, this also gives us the opportunity to split the data into two sets: the minimum needed to evaluate the install scheme paths, and the non-critical additional data we expose in sysconfig.get_config_vars. This would help with the bootstrapping issue in python -m sysconfig --generate-posix-vars.

# There's a chicken-and-egg situation on OS X with regards to the
# _sysconfigdata module after the changes introduced by #15298:
# get_config_vars() is called by get_platform() as part of the
# `make pybuilddir.txt` target -- which is a precursor to the
# _sysconfigdata.py module being constructed. Unfortunately,
# get_config_vars() eventually calls _init_posix(), which attempts
# to import _sysconfigdata, which we won't have built yet. In order
# for _init_posix() to work, if we're on Darwin, just mock up the
# _sysconfigdata module manually and populate it with the build vars.
# This is more than sufficient for ensuring the subsequent call to
# get_platform() succeeds.
# GH-127178: Since we started generating a .json file, we also need this to
# be able to run sysconfig.get_config_vars().
module = types.ModuleType(name)
module.build_time_vars = vars
sys.modules[name] = module

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions