Skip to content

Commit cc8a5cb

Browse files
committed
cleanup
1 parent a0cb8ed commit cc8a5cb

File tree

6 files changed

+12
-33
lines changed

6 files changed

+12
-33
lines changed

MODULE.bazel

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,11 @@ dev_python.override(
125125
register_all_versions = True,
126126
)
127127

128-
# Necessary so single_version_platform_override with a new version works
129-
##dev_python.toolchain(python_version = "3.13")
130-
131128
# For testing an arbitrary runtime triggered by a custom flag.
132129
# See //tests/toolchains:custom_platform_toolchain_test
133130
dev_python.single_version_platform_override(
134131
platform = "linux-x86-install-only-stripped",
135-
##python_version = "3.13.3",
136132
python_version = "3.13.1",
137-
##sha256 = "01d08b9bc8a96698b9d64c2fc26da4ecc4fa9e708ce0a34fb88f11ab7e552cbd",
138133
sha256 = "56817aa976e4886bec1677699c136cb01c1cdfe0495104c0d8ef546541864bbb",
139134
target_compatible_with = [
140135
"@platforms//os:linux",
@@ -144,7 +139,6 @@ dev_python.single_version_platform_override(
144139
"@@//tests/support:is_custom_runtime_linux-x86-install-only-stripped",
145140
],
146141
urls = ["https://github.com/astral-sh/python-build-standalone/releases/download/20250115/cpython-3.13.1+20250115-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz"],
147-
##urls = ["https://github.com/astral-sh/python-build-standalone/releases/download/20250409/cpython-3.13.3+20250409-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz"],
148142
)
149143

150144
dev_pip = use_extension(

docs/toolchains.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ that is activated for Linux x86 builds when the custom flag
261261
bazel_dep(name = "bazel_skylib", version = "1.7.1.")
262262
bazel_dep(name = "rules_python", version = "1.5.0")
263263
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
264-
python.toolchain(python_version="3.13.3")
265264
python.single_version_platform_override(
266265
platform = "my-platform",
267266
python_version = "3.13.3",
@@ -290,8 +289,6 @@ config_setting(
290289
Notes:
291290
- While any URL and archive can be used, it's assumed their content looks how
292291
a python-build-standalone archive looks.
293-
- `python.toolchain()` is required if the version is unknown; if the version
294-
is already known, it can be omitted.
295292
- A "version aware" toolchain is registered, which means the Python version flag
296293
must also match (e.g. `--@rules_python//python/config_settings:python_version=3.13.3`
297294
must be set -- see `minor_mapping` and `is_default` for controls and docs

python/private/python.bzl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def parse_modules(*, module_ctx, logger, _fail = fail):
3737
3838
Args:
3939
module_ctx: {type}`module_ctx` module context.
40+
logger: {type}`repo_utils.logger` A logger to use.
4041
_fail: {type}`function` the failure function, mainly for testing.
4142
4243
Returns:
@@ -335,7 +336,6 @@ def _python_impl(module_ctx):
335336
**kwargs
336337
)
337338
if not register_result.impl_repos:
338-
fail("hit")
339339
continue
340340

341341
host_platforms = {}
@@ -674,13 +674,7 @@ def _process_single_version_platform_overrides(*, tag, _fail = fail, default):
674674
if tag.sha256:
675675
available_versions[tag.python_version].setdefault("sha256", {})[tag.platform] = tag.sha256
676676
if tag.strip_prefix:
677-
v = available_versions
678-
v1 = available_versions[tag.python_version]
679-
v1.setdefault("strip_prefix", {})
680-
v2 = v1["strip_prefix"]
681-
print(v2)
682-
v2[tag.platform] = tag.strip_prefix
683-
##available_versions[tag.python_version].setdefault("strip_prefix", {})[tag.platform] = tag.strip_prefix
677+
available_versions[tag.python_version].setdefault("strip_prefix", {})[tag.platform] = tag.strip_prefix
684678

685679
if tag.urls:
686680
available_versions[tag.python_version].setdefault("url", {})[tag.platform] = tag.urls
@@ -712,7 +706,9 @@ def _process_single_version_platform_overrides(*, tag, _fail = fail, default):
712706
arch = "UNKNOWN_CUSTOM_ARCH"
713707

714708
# Move the override earlier in the ordering -- the platform key ordering
715-
# becomes the toolchain ordering within the version.
709+
# becomes the toolchain ordering within the version. This allows the
710+
# override to have a superset of constraints from a regular runtimes
711+
# (e.g. same platform, but with a custom flag required).
716712
override_first = {
717713
tag.platform: platform_info(
718714
compatible_with = target_compatible_with,

python/private/pythons_hub.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ This rule also writes out the various toolchains for the different Python versio
141141
""",
142142
implementation = _hub_repo_impl,
143143
attrs = {
144+
"default_python_version": attr.string(
145+
doc = "Default Python version for the build in `X.Y` or `X.Y.Z` format.",
146+
mandatory = True,
147+
),
144148
"host_compatible_repo_names": attr.string_list(
145149
doc = "The base repo name for toolchains ('python_3_10', no " +
146150
"platform suffix)",
147151
mandatory = True,
148152
),
149-
"default_python_version": attr.string(
150-
doc = "Default Python version for the build in `X.Y` or `X.Y.Z` format.",
151-
mandatory = True,
152-
),
153153
"minor_mapping": attr.string_dict(
154154
doc = "The minor mapping of the `X.Y` to `X.Y.Z` format that is used in config settings.",
155155
mandatory = True,

python/private/repo_utils.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,13 @@ def _get_platforms_cpu_name(mrctx = None, *, arch = None):
405405
406406
Args:
407407
mrctx: module_ctx or repository_ctx.
408+
arch: {type}`str` Arch to map to @platforms cpu. If not set, taken
409+
from `mrctx`.
408410
409411
Returns:
410412
`str`. The target name.
411413
"""
412-
if mrctx:
414+
if arch == None:
413415
arch = mrctx.os.arch.lower()
414416

415417
if arch in ["i386", "i486", "i586", "i686", "i786", "x86"]:

python/private/toolchains_repo.bzl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -604,26 +604,16 @@ def _get_host_impl_repo_name(*, rctx, logger, python_version, os_name, cpu_name,
604604
candidates,
605605
))
606606
elif preference not in candidates:
607-
# todo: need to map names like 3_13_0_linux_x86_64 back to
608-
# the input values. Ah, er, wait
609-
# Is this working?
610-
# The return value is appended to this repo's name.
611-
# This repo's name is e.g. python_3_13.
612-
# the net result would be
613-
# python_3_10_3_13_0_linux_x86_64
614-
# which isn't a valid name
615607
return logger.fail("Please choose a preferred interpreter out of the following platforms: {}".format(candidates))
616608
else:
617609
candidates = [preference]
618610

619611
if candidates:
620612
platform_name, meta = candidates[0]
621-
print("multiple candidates:", candidates)
622613
suffix = getattr(meta, "impl_repo_name", None)
623614
if not suffix:
624615
suffix = platform_name
625616
return suffix
626-
##return getattr(meta, "impl_repo_name", platform_name)
627617

628618
return logger.fail("Could not find a compatible 'host' python for '{os_name}', '{cpu_name}' from the loaded platforms: {platforms}".format(
629619
os_name = os_name,

0 commit comments

Comments
 (0)