-
-
Notifications
You must be signed in to change notification settings - Fork 240
Strip versioned Xcode path from build flags #414
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -587,6 +587,7 @@ fi | |
| # that a) it works on as many machines as possible b) doesn't leak details | ||
| # about the build environment, which is non-portable. | ||
| cat > ${ROOT}/hack_sysconfig.py << EOF | ||
| import json | ||
| import os | ||
| import sys | ||
| import sysconfig | ||
|
|
@@ -628,6 +629,41 @@ def replace_in_all(search, replace): | |
| replace_in_file(SYSCONFIGDATA, search, replace) | ||
|
|
||
|
|
||
| def format_sysconfigdata(): | ||
| """Reformat the sysconfigdata file to avoid implicit string concatenations. | ||
|
|
||
| In some Python versions, the sysconfigdata file contains implicit string | ||
| concatenations that extend over multiple lines, which make string replacement | ||
| much harder. This function reformats the file to avoid this issue. | ||
|
|
||
| See: https://github.com/python/cpython/blob/a03efb533a58fd13fb0cc7f4a5c02c8406a407bd/Mac/BuildScript/build-installer.py#L1360C1-L1385C15. | ||
| """ | ||
| with open(SYSCONFIGDATA, "rb") as fh: | ||
| data = fh.read() | ||
|
|
||
| globals_dict = {} | ||
| locals_dict = {} | ||
| exec(data, globals_dict, locals_dict) | ||
| build_time_vars = locals_dict['build_time_vars'] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we assert there aren't other variables so this doesn't break something in the future? |
||
|
|
||
| with open(SYSCONFIGDATA, "wb") as fh: | ||
| fh.write(b'# system configuration generated and used by the sysconfig module\n') | ||
| fh.write(('build_time_vars = %s' % json.dumps(build_time_vars, indent=4)).encode("utf-8")) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need a sort_keys=True to make the output deterministic? If there are any dicts, it does. |
||
| fh.close() | ||
|
|
||
|
|
||
| # Format sysconfig to ensure that string replacements take effect. | ||
| format_sysconfigdata() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't reformat the sysconfig data file, then |
||
|
|
||
| # Remove the Xcode path from the compiler flags. | ||
| # | ||
| # CPython itself will drop this from `sysconfig.get_config_var("CFLAGS")` and | ||
| # similar calls, but _not_ if `CFLAGS` is set in the environment (regardless of | ||
| # the `CFLAGS` value). It will almost always be wrong, so we drop it unconditionally. | ||
| xcode_path = os.getenv("APPLE_SDK_PATH") | ||
| if xcode_path: | ||
| replace_in_all("-isysroot %s" % xcode_path, "") | ||
|
|
||
| # -fdebug-default-version is Clang only. Strip so compiling works on GCC. | ||
| replace_in_all("-fdebug-default-version=4", "") | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.