Patch sysconfig data at install time (#9857)

## Summary

This PR reimplements
[`sysconfigpatcher`](https://github.com/bluss/sysconfigpatcher) in Rust
and applies it to our Python installations at install-time, ensuring
that the `sysconfig` data is more likely to be correct.

For now, we only rewrite prefixes (i.e., any path that starts with
`/install` gets rewritten to the correct absolute path for the current
machine).

Unlike `sysconfigpatcher`, this PR does not yet do any of the following:

- Patch `pkginfo` files.
- Change `clang` references to `cc`.

A few things that we should do as follow-ups, in my opinion:

1. Rewrite
[`AR`](c1ebf8ab92/src/sysconfigpatcher.py (L61)).
2. Remove `-isysroot`, which we already do for newer builds.
This commit is contained in:
Charlie Marsh 2024-12-13 14:36:22 -05:00 committed by GitHub
parent 5903ce5759
commit d2fb4c585d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 817 additions and 19 deletions

View file

@ -573,7 +573,10 @@ def main() -> None:
"sys_executable": sys.executable,
"sys_path": sys.path,
"stdlib": sysconfig.get_path("stdlib"),
"sysconfig_prefix": sysconfig.get_config_var("prefix"),
# Prior to the introduction of `sysconfig` patching, python-build-standalone installations would always use
# "/install" as the prefix. With `sysconfig` patching, we rewrite the prefix to match the actual installation
# location. So in newer versions, we also write a dedicated flag to indicate standalone builds.
"standalone": sysconfig.get_config_var("prefix") == "/install" or bool(sysconfig.get_config_var("PYTHON_BUILD_STANDALONE")),
"scheme": get_scheme(),
"virtualenv": get_virtualenv(),
"platform": os_and_arch,