-
Notifications
You must be signed in to change notification settings - Fork 543
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
Added arg for free threading support #2129
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 | ||||
---|---|---|---|---|---|---|
|
@@ -357,6 +357,13 @@ def _process_single_version_overrides(*, tag, _fail = fail, default): | |||||
for platform in sha256 | ||||||
} | ||||||
|
||||||
if tag.flag_values: | ||||||
# Normalize flag keys to strings | ||||||
flag_values = {str(k): v for k, v in tag.flag_values.items()} | ||||||
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. I think the normalization should be done inside |
||||||
override["flag_values"] = flag_values | ||||||
if tag.suffix: | ||||||
override["suffix"] = tag.suffix | ||||||
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. The I am under an assumption that these will be two separate |
||||||
|
||||||
available_versions[tag.python_version] = {k: v for k, v in override.items() if v} | ||||||
|
||||||
if tag.distutils_content: | ||||||
|
@@ -789,6 +796,15 @@ class. | |||||
mandatory = False, | ||||||
doc = "The URL template to fetch releases for this Python version. See {attr}`python.single_version_platform_override.urls` for documentation.", | ||||||
), | ||||||
"flag_values": attr.string_dict( | ||||||
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. This should be the following type.
Suggested change
|
||||||
mandatory = False, | ||||||
doc = "TODO", | ||||||
), | ||||||
"suffix": attr.string( | ||||||
mandatory = False, | ||||||
doc = "TODO", | ||||||
default = "", | ||||||
) | ||||||
}, | ||||||
) | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ def _python_repository_impl(rctx): | |
release_filename = rctx.attr.release_filename | ||
urls = rctx.attr.urls or [rctx.attr.url] | ||
auth = get_auth(rctx, urls) | ||
free_threading = rctx.attr.free_threading | ||
|
||
if release_filename.endswith(".zst"): | ||
rctx.download( | ||
|
@@ -126,11 +127,12 @@ def _python_repository_impl(rctx): | |
for patch in patches: | ||
rctx.patch(patch, strip = rctx.attr.patch_strip) | ||
|
||
ft_postfix = "t" if free_threading else "" | ||
# Write distutils.cfg to the Python installation. | ||
if "windows" in platform: | ||
distutils_path = "Lib/distutils/distutils.cfg" | ||
else: | ||
distutils_path = "lib/python{}/distutils/distutils.cfg".format(python_short_version) | ||
distutils_path = "lib/python{}{}/distutils/distutils.cfg".format(python_short_version, ft_postfix) | ||
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. I think the |
||
if rctx.attr.distutils: | ||
rctx.file(distutils_path, rctx.read(rctx.attr.distutils)) | ||
elif rctx.attr.distutils_content: | ||
|
@@ -143,7 +145,7 @@ def _python_repository_impl(rctx): | |
# dyld lookup errors. To fix, set the full path to the dylib as | ||
# it appears in the Bazel workspace as its LC_ID_DYLIB using | ||
# the `install_name_tool` bundled with macOS. | ||
dylib = "libpython{}.dylib".format(python_short_version) | ||
dylib = "libpython{}{}.dylib".format(python_short_version, ft_postfix) | ||
repo_utils.execute_checked( | ||
rctx, | ||
op = "python_repository.FixUpDyldIdPath", | ||
|
@@ -255,13 +257,15 @@ define_hermetic_runtime_toolchain_impl( | |
python_version = {python_version}, | ||
python_bin = {python_bin}, | ||
coverage_tool = {coverage_tool}, | ||
free_threading = {free_threading}, | ||
) | ||
""".format( | ||
extra_files_glob_exclude = render.list(glob_exclude), | ||
extra_files_glob_include = render.list(glob_include), | ||
python_bin = render.str(python_bin), | ||
python_version = render.str(rctx.attr.python_version), | ||
coverage_tool = render.str(coverage_tool), | ||
free_threading = free_threading, | ||
) | ||
rctx.delete("python") | ||
rctx.symlink(python_bin, "python") | ||
|
@@ -321,6 +325,10 @@ For more information see {attr}`py_runtime.coverage_tool`. | |
"Either distutils or distutils_content can be specified, but not both.", | ||
mandatory = False, | ||
), | ||
"free_threading": attr.bool( | ||
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 are adding this arg, it should also be added to |
||
doc = "Whether we use CPython interpreter in free-threading mode (disabled GIL).", | ||
default = False, | ||
), | ||
"ignore_root_user_error": attr.bool( | ||
default = False, | ||
doc = "Whether the check for root should be ignored or not. This causes cache misses with .pyc files.", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking out loud, I am wondering if it makes sense to define a config setting using the free threading arg here and just include the files conditionally. That way we don't need to pass an extra
free_threading
bool arg to this macro, which could make things easier to maintain.