Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
websockets ; python_full_version > "3.9.1"
websockets ; python_full_version > "3.11"
Original file line number Diff line number Diff line change
Expand Up @@ -4,75 +4,3 @@
#
# bazel run //requirements:requirements_3_10.update
#
websockets==11.0.3 ; python_full_version > "3.9.1" \
--hash=sha256:01f5567d9cf6f502d655151645d4e8b72b453413d3819d2b6f1185abc23e82dd \
--hash=sha256:03aae4edc0b1c68498f41a6772d80ac7c1e33c06c6ffa2ac1c27a07653e79d6f \
--hash=sha256:0ac56b661e60edd453585f4bd68eb6a29ae25b5184fd5ba51e97652580458998 \
--hash=sha256:0ee68fe502f9031f19d495dae2c268830df2760c0524cbac5d759921ba8c8e82 \
--hash=sha256:1553cb82942b2a74dd9b15a018dce645d4e68674de2ca31ff13ebc2d9f283788 \
--hash=sha256:1a073fc9ab1c8aff37c99f11f1641e16da517770e31a37265d2755282a5d28aa \
--hash=sha256:1d2256283fa4b7f4c7d7d3e84dc2ece74d341bce57d5b9bf385df109c2a1a82f \
--hash=sha256:1d5023a4b6a5b183dc838808087033ec5df77580485fc533e7dab2567851b0a4 \
--hash=sha256:1fdf26fa8a6a592f8f9235285b8affa72748dc12e964a5518c6c5e8f916716f7 \
--hash=sha256:2529338a6ff0eb0b50c7be33dc3d0e456381157a31eefc561771ee431134a97f \
--hash=sha256:279e5de4671e79a9ac877427f4ac4ce93751b8823f276b681d04b2156713b9dd \
--hash=sha256:2d903ad4419f5b472de90cd2d40384573b25da71e33519a67797de17ef849b69 \
--hash=sha256:332d126167ddddec94597c2365537baf9ff62dfcc9db4266f263d455f2f031cb \
--hash=sha256:34fd59a4ac42dff6d4681d8843217137f6bc85ed29722f2f7222bd619d15e95b \
--hash=sha256:3580dd9c1ad0701169e4d6fc41e878ffe05e6bdcaf3c412f9d559389d0c9e016 \
--hash=sha256:3ccc8a0c387629aec40f2fc9fdcb4b9d5431954f934da3eaf16cdc94f67dbfac \
--hash=sha256:41f696ba95cd92dc047e46b41b26dd24518384749ed0d99bea0a941ca87404c4 \
--hash=sha256:42cc5452a54a8e46a032521d7365da775823e21bfba2895fb7b77633cce031bb \
--hash=sha256:4841ed00f1026dfbced6fca7d963c4e7043aa832648671b5138008dc5a8f6d99 \
--hash=sha256:4b253869ea05a5a073ebfdcb5cb3b0266a57c3764cf6fe114e4cd90f4bfa5f5e \
--hash=sha256:54c6e5b3d3a8936a4ab6870d46bdd6ec500ad62bde9e44462c32d18f1e9a8e54 \
--hash=sha256:619d9f06372b3a42bc29d0cd0354c9bb9fb39c2cbc1a9c5025b4538738dbffaf \
--hash=sha256:6505c1b31274723ccaf5f515c1824a4ad2f0d191cec942666b3d0f3aa4cb4007 \
--hash=sha256:660e2d9068d2bedc0912af508f30bbeb505bbbf9774d98def45f68278cea20d3 \
--hash=sha256:6681ba9e7f8f3b19440921e99efbb40fc89f26cd71bf539e45d8c8a25c976dc6 \
--hash=sha256:68b977f21ce443d6d378dbd5ca38621755f2063d6fdb3335bda981d552cfff86 \
--hash=sha256:69269f3a0b472e91125b503d3c0b3566bda26da0a3261c49f0027eb6075086d1 \
--hash=sha256:6f1a3f10f836fab6ca6efa97bb952300b20ae56b409414ca85bff2ad241d2a61 \
--hash=sha256:7622a89d696fc87af8e8d280d9b421db5133ef5b29d3f7a1ce9f1a7bf7fcfa11 \
--hash=sha256:777354ee16f02f643a4c7f2b3eff8027a33c9861edc691a2003531f5da4f6bc8 \
--hash=sha256:84d27a4832cc1a0ee07cdcf2b0629a8a72db73f4cf6de6f0904f6661227f256f \
--hash=sha256:8531fdcad636d82c517b26a448dcfe62f720e1922b33c81ce695d0edb91eb931 \
--hash=sha256:86d2a77fd490ae3ff6fae1c6ceaecad063d3cc2320b44377efdde79880e11526 \
--hash=sha256:88fc51d9a26b10fc331be344f1781224a375b78488fc343620184e95a4b27016 \
--hash=sha256:8a34e13a62a59c871064dfd8ffb150867e54291e46d4a7cf11d02c94a5275bae \
--hash=sha256:8c82f11964f010053e13daafdc7154ce7385ecc538989a354ccc7067fd7028fd \
--hash=sha256:92b2065d642bf8c0a82d59e59053dd2fdde64d4ed44efe4870fa816c1232647b \
--hash=sha256:97b52894d948d2f6ea480171a27122d77af14ced35f62e5c892ca2fae9344311 \
--hash=sha256:9d9acd80072abcc98bd2c86c3c9cd4ac2347b5a5a0cae7ed5c0ee5675f86d9af \
--hash=sha256:9f59a3c656fef341a99e3d63189852be7084c0e54b75734cde571182c087b152 \
--hash=sha256:aa5003845cdd21ac0dc6c9bf661c5beddd01116f6eb9eb3c8e272353d45b3288 \
--hash=sha256:b16fff62b45eccb9c7abb18e60e7e446998093cdcb50fed33134b9b6878836de \
--hash=sha256:b30c6590146e53149f04e85a6e4fcae068df4289e31e4aee1fdf56a0dead8f97 \
--hash=sha256:b58cbf0697721120866820b89f93659abc31c1e876bf20d0b3d03cef14faf84d \
--hash=sha256:b67c6f5e5a401fc56394f191f00f9b3811fe843ee93f4a70df3c389d1adf857d \
--hash=sha256:bceab846bac555aff6427d060f2fcfff71042dba6f5fca7dc4f75cac815e57ca \
--hash=sha256:bee9fcb41db2a23bed96c6b6ead6489702c12334ea20a297aa095ce6d31370d0 \
--hash=sha256:c114e8da9b475739dde229fd3bc6b05a6537a88a578358bc8eb29b4030fac9c9 \
--hash=sha256:c1f0524f203e3bd35149f12157438f406eff2e4fb30f71221c8a5eceb3617b6b \
--hash=sha256:c792ea4eabc0159535608fc5658a74d1a81020eb35195dd63214dcf07556f67e \
--hash=sha256:c7f3cb904cce8e1be667c7e6fef4516b98d1a6a0635a58a57528d577ac18a128 \
--hash=sha256:d67ac60a307f760c6e65dad586f556dde58e683fab03323221a4e530ead6f74d \
--hash=sha256:dcacf2c7a6c3a84e720d1bb2b543c675bf6c40e460300b628bab1b1efc7c034c \
--hash=sha256:de36fe9c02995c7e6ae6efe2e205816f5f00c22fd1fbf343d4d18c3d5ceac2f5 \
--hash=sha256:def07915168ac8f7853812cc593c71185a16216e9e4fa886358a17ed0fd9fcf6 \
--hash=sha256:df41b9bc27c2c25b486bae7cf42fccdc52ff181c8c387bfd026624a491c2671b \
--hash=sha256:e052b8467dd07d4943936009f46ae5ce7b908ddcac3fda581656b1b19c083d9b \
--hash=sha256:e063b1865974611313a3849d43f2c3f5368093691349cf3c7c8f8f75ad7cb280 \
--hash=sha256:e1459677e5d12be8bbc7584c35b992eea142911a6236a3278b9b5ce3326f282c \
--hash=sha256:e1a99a7a71631f0efe727c10edfba09ea6bee4166a6f9c19aafb6c0b5917d09c \
--hash=sha256:e590228200fcfc7e9109509e4d9125eace2042fd52b595dd22bbc34bb282307f \
--hash=sha256:e6316827e3e79b7b8e7d8e3b08f4e331af91a48e794d5d8b099928b6f0b85f20 \
--hash=sha256:e7837cb169eca3b3ae94cc5787c4fed99eef74c0ab9506756eea335e0d6f3ed8 \
--hash=sha256:e848f46a58b9fcf3d06061d17be388caf70ea5b8cc3466251963c8345e13f7eb \
--hash=sha256:ed058398f55163a79bb9f06a90ef9ccc063b204bb346c4de78efc5d15abfe602 \
--hash=sha256:f2e58f2c36cc52d41f2659e4c0cbf7353e28c8c9e63e30d8c6d3494dc9fdedcf \
--hash=sha256:f467ba0050b7de85016b43f5a22b46383ef004c4f672148a8abf32bc999a87f0 \
--hash=sha256:f61bdb1df43dc9c131791fbc2355535f9024b9a04398d3bd0684fc16ab07df74 \
--hash=sha256:fb06eea71a00a7af0ae6aefbb932fb8a7df3cb390cc217d51a9ad7343de1b8d0 \
--hash=sha256:ffd7dcaf744f25f82190856bc26ed81721508fc5cbf2a330751e135ff1283564
# via -r requirements/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# bazel run //requirements:requirements_3_11.update
#
websockets==11.0.3 ; python_full_version > "3.9.1" \
websockets==11.0.3 ; python_full_version > "3.11" \
--hash=sha256:01f5567d9cf6f502d655151645d4e8b72b453413d3819d2b6f1185abc23e82dd \
--hash=sha256:03aae4edc0b1c68498f41a6772d80ac7c1e33c06c6ffa2ac1c27a07653e79d6f \
--hash=sha256:0ac56b661e60edd453585f4bd68eb6a29ae25b5184fd5ba51e97652580458998 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# bazel run //requirements:requirements_3_12.update
#
websockets==11.0.3 ; python_full_version > "3.9.1" \
websockets==11.0.3 ; python_full_version > "3.11" \
--hash=sha256:01f5567d9cf6f502d655151645d4e8b72b453413d3819d2b6f1185abc23e82dd \
--hash=sha256:03aae4edc0b1c68498f41a6772d80ac7c1e33c06c6ffa2ac1c27a07653e79d6f \
--hash=sha256:0ac56b661e60edd453585f4bd68eb6a29ae25b5184fd5ba51e97652580458998 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# bazel run //requirements:requirements_3_13.update
#
websockets==11.0.3 ; python_full_version > "3.9.1" \
websockets==11.0.3 ; python_full_version > "3.11" \
--hash=sha256:01f5567d9cf6f502d655151645d4e8b72b453413d3819d2b6f1185abc23e82dd \
--hash=sha256:03aae4edc0b1c68498f41a6772d80ac7c1e33c06c6ffa2ac1c27a07653e79d6f \
--hash=sha256:0ac56b661e60edd453585f4bd68eb6a29ae25b5184fd5ba51e97652580458998 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# bazel run //requirements:requirements_3_14.update
#
websockets==11.0.3 ; python_full_version > "3.9.1" \
websockets==11.0.3 ; python_full_version > "3.11" \
--hash=sha256:01f5567d9cf6f502d655151645d4e8b72b453413d3819d2b6f1185abc23e82dd \
--hash=sha256:03aae4edc0b1c68498f41a6772d80ac7c1e33c06c6ffa2ac1c27a07653e79d6f \
--hash=sha256:0ac56b661e60edd453585f4bd68eb6a29ae25b5184fd5ba51e97652580458998 \
Expand Down
8 changes: 8 additions & 0 deletions python/private/pypi/pkg_aliases.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ def pkg_aliases(
if target_name.startswith("_"):
kwargs["visibility"] = ["//_groups:__subpackages__"]

if type(actual) == type({}):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For clarity and to follow Starlark's idiomatic style, it's better to compare the type string directly, i.e., type(actual) == "dict" instead of type(actual) == type({}). This improves readability.

Suggested change
if type(actual) == type({}):
if type(actual) == "dict":

kwargs["target_compatible_with"] = select({
k: []
for k in actual.keys()
} | {
"//conditions:default": ["@platforms//:incompatible"],
})

alias(
name = target_name,
actual = _actual,
Expand Down
23 changes: 12 additions & 11 deletions python/private/pypi/whl_library_alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
"""whl_library aliases for multi_pip_parse."""

load("//python/private:full_version.bzl", "full_version")
load(":render_pkg_aliases.bzl", "NO_MATCH_ERROR_MESSAGE_TEMPLATE")

def _whl_library_alias_impl(rctx):
rules_python = rctx.attr._rules_python_workspace.repo_name
if rctx.attr.default_version:
default_repo_prefix = rctx.attr.version_map[rctx.attr.default_version]
default_repo_prefix = rctx.attr.version_map.get(rctx.attr.default_version, None)
else:
default_repo_prefix = None
version_map = rctx.attr.version_map.items()
Expand Down Expand Up @@ -70,16 +69,18 @@ alias(
))

alias.append(" },") # Close select expression condition dict
if not default_repo_prefix:
supported_versions = sorted([python_version for python_version, _ in version_map])
alias.append(' no_match_error="""{}""",'.format(
NO_MATCH_ERROR_MESSAGE_TEMPLATE.format(
supported_versions = ", ".join(supported_versions),
rules_python = rules_python,
),
))
alias.append(" ),") # Close the select expression
alias.append(' visibility = ["//visibility:public"],')
if not default_repo_prefix:
alias.append(" target_compatible_with = select({")
for [python_version, _] in version_map:
alias.append("""\
"@{rules_python}//python/config_settings:is_python_{full_python_version}": [],""".format(
full_python_version = full_version(version = python_version, minor_mapping = minor_mapping),
rules_python = rules_python,
))
alias.append(' "//conditions:default": ["@platforms//:incompatible"],')
alias.append(" }),") # Close the select expression
alias.append(")") # Close the alias() expression
return "\n".join(alias)

Expand All @@ -93,7 +94,7 @@ whl_library_alias = repository_rule(
"from `version_map` don't match. This allows the default " +
"(version unaware) rules to match and select a wheel. If " +
"not specified, then the default rules won't be able to " +
"resolve a wheel and an error will occur.",
"resolve a wheel and the target will be incompatible.",
),
"minor_mapping": attr.string_dict(mandatory = True),
"version_map": attr.string_dict(mandatory = True),
Expand Down
8 changes: 4 additions & 4 deletions tests/pypi/pkg_aliases/pkg_aliases_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _test_legacy_aliases(env):
name = "foo",
actual = "repo",
native = struct(
alias = lambda name, actual: got.update({name: actual}),
alias = lambda name, actual, *, target_compatible_with = None: got.update({name: actual}),
),
extra_aliases = ["my_special"],
)
Expand Down Expand Up @@ -69,7 +69,7 @@ def _test_config_setting_aliases(env):
},
extra_aliases = ["my_special"],
native = struct(
alias = lambda *, name, actual, visibility = None, tags = None: got.update({name: actual}),
alias = lambda *, name, actual, visibility = None, tags = None, target_compatible_with = None: got.update({name: actual}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The tests should be updated to assert that target_compatible_with is being set correctly. Currently, the new target_compatible_with parameter is accepted by the mock alias but its value is not checked.

You could modify the mock to store the target_compatible_with value and then add assertions to verify it. For example, in _test_config_setting_aliases you could do:

    # In _test_config_setting_aliases
    got_compatible_with = {}

    def mock_alias(*, name, actual, visibility = None, tags = None, target_compatible_with = None):
        got.update({name: actual})
        if target_compatible_with:
            got_compatible_with[name] = target_compatible_with

    # ... inside pkg_aliases call
    native = struct(
        alias = mock_alias
    )

    # ... after pkg_aliases call
    # The result of selects.with_or is a dict for the select() statement.
    # We can check its contents.
    env.expect.that_dict(got_compatible_with["pkg"]).to_be({
        "//:my_config_setting": [],
        "//conditions:default": ["@platforms//:incompatible"],
    })

This would ensure the new logic is correctly tested across different scenarios (e.g., with single config settings, multiple, and with whl_config_setting).

),
select = mock_select,
)
Expand Down Expand Up @@ -118,7 +118,7 @@ def _test_config_setting_aliases_many(env):
},
extra_aliases = ["my_special"],
native = struct(
alias = lambda *, name, actual, visibility = None, tags = None: got.update({name: actual}),
alias = lambda *, name, actual, visibility = None, tags = None, target_compatible_with = None: got.update({name: actual}),
config_setting = lambda **_: None,
),
select = mock_select,
Expand Down Expand Up @@ -170,7 +170,7 @@ def _test_multiplatform_whl_aliases(env):
},
extra_aliases = [],
native = struct(
alias = lambda *, name, actual, visibility = None, tags = None: got.update({name: actual}),
alias = lambda *, name, actual, visibility = None, tags = None, target_compatible_with = None: got.update({name: actual}),
),
select = mock_select,
)
Expand Down