Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
FFY00 opened this issue Dec 18, 2024 · 0 comments
Labels
topic-sysconfig type-feature A feature request or enhancement

Comments

@FFY00
Copy link
Member

FFY00 commented Dec 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-sysconfig type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant