Skip to content

Commit 855a673

Browse files
committed
Merge branch 'test/independent-platforms' into exp/pypi-simplify
2 parents 5c29535 + a5dc20c commit 855a673

File tree

3 files changed

+158
-227
lines changed

3 files changed

+158
-227
lines changed

MODULE.bazel

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,77 @@ register_toolchains("@pythons_hub//:all")
6060
# Install twine for our own runfiles wheel publishing and allow bzlmod users to use it.
6161

6262
pip = use_extension("//python/extensions:pip.bzl", "pip")
63+
64+
# NOTE @aignas 2025-07-06: we define these platforms to keep backwards compatibility with the
65+
# current `experimental_index_url` implementation. Whilst we stabilize the API this list may be
66+
# updated with a mention in the CHANGELOG.
67+
[
68+
pip.default(
69+
arch_name = cpu,
70+
config_settings = [
71+
"@platforms//cpu:{}".format(cpu),
72+
"@platforms//os:linux",
73+
],
74+
env = {"platform_version": "0"},
75+
os_name = "linux",
76+
platform = "linux_{}".format(cpu),
77+
platform_tags = [
78+
"linux_*_{}".format(cpu),
79+
"manylinux_*_{}".format(cpu),
80+
],
81+
)
82+
for cpu in [
83+
"x86_64",
84+
"aarch64",
85+
# TODO @aignas 2025-05-19: only leave tier 0-1 cpus when stabilizing the
86+
# `pip.default` extension. i.e. drop the below values - users will have to
87+
# define themselves if they need them.
88+
"arm",
89+
"ppc",
90+
"s390x",
91+
]
92+
]
93+
94+
[
95+
pip.default(
96+
arch_name = cpu,
97+
config_settings = [
98+
"@platforms//cpu:{}".format(cpu),
99+
"@platforms//os:osx",
100+
],
101+
# We choose the oldest non-EOL version at the time when we release `rules_python`.
102+
# See https://endoflife.date/macos
103+
env = {"platform_version": "14.0"},
104+
os_name = "osx",
105+
platform = "osx_{}".format(cpu),
106+
platform_tags = [
107+
"macosx_*_{}".format(suffix)
108+
for suffix in platform_tag_cpus
109+
],
110+
)
111+
for cpu, platform_tag_cpus in {
112+
"aarch64": [
113+
"universal2",
114+
"arm64",
115+
],
116+
"x86_64": [
117+
"universal2",
118+
"x86_64",
119+
],
120+
}.items()
121+
]
122+
123+
pip.default(
124+
arch_name = "x86_64",
125+
config_settings = [
126+
"@platforms//cpu:x86_64",
127+
"@platforms//os:windows",
128+
],
129+
env = {"platform_version": "0"},
130+
os_name = "windows",
131+
platform = "windows_x86_64",
132+
platform_tags = ["win_amd64"],
133+
)
63134
pip.parse(
64135
# NOTE @aignas 2024-10-26: We have an integration test that depends on us
65136
# being able to build sdists for this hub, so explicitly set this to False.

python/private/pypi/extension.bzl

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -425,87 +425,6 @@ def _configure(config, *, platform, os_name, arch_name, config_settings, env = {
425425
else:
426426
config["platforms"].pop(platform)
427427

428-
def _set_defaults(defaults):
429-
"""Set defaults that rules_python is operating under.
430-
431-
Because this code is also tested in unit tests, leaving it in MODULE.bazel would be
432-
a little problematic.
433-
"""
434-
435-
# NOTE: We have this so that it is easier to maintain unit tests assuming certain
436-
# defaults
437-
for cpu in [
438-
"x86_64",
439-
"aarch64",
440-
# TODO @aignas 2025-05-19: only leave tier 0-1 cpus when stabilizing the
441-
# `pip.default` extension. i.e. drop the below values - users will have to
442-
# define themselves if they need them.
443-
"arm",
444-
"ppc",
445-
"s390x",
446-
]:
447-
_configure(
448-
defaults,
449-
arch_name = cpu,
450-
os_name = "linux",
451-
platform = "linux_{}".format(cpu),
452-
want_abis = [],
453-
config_settings = [
454-
"@platforms//os:linux",
455-
"@platforms//cpu:{}".format(cpu),
456-
],
457-
platform_tags = [
458-
"linux_*_{}".format(cpu),
459-
"manylinux_*_{}".format(cpu),
460-
],
461-
env = {
462-
"platform_version": "0",
463-
},
464-
)
465-
for cpu, platform_tag_cpus in {
466-
"aarch64": ["universal2", "arm64"],
467-
"x86_64": ["universal2", "x86_64"],
468-
}.items():
469-
_configure(
470-
defaults,
471-
arch_name = cpu,
472-
os_name = "osx",
473-
platform = "osx_{}".format(cpu),
474-
config_settings = [
475-
"@platforms//os:osx",
476-
"@platforms//cpu:{}".format(cpu),
477-
],
478-
want_abis = [],
479-
platform_tags = [
480-
"macosx_*_{}".format(suffix)
481-
for suffix in platform_tag_cpus
482-
],
483-
# We choose the oldest non-EOL version at the time when we release `rules_python`.
484-
# See https://endoflife.date/macos
485-
env = {
486-
"platform_version": "14.0",
487-
},
488-
)
489-
490-
for cpu, platform_tags in {
491-
"x86_64": ["win_amd64"],
492-
}.items():
493-
_configure(
494-
defaults,
495-
arch_name = cpu,
496-
os_name = "windows",
497-
platform = "windows_{}".format(cpu),
498-
config_settings = [
499-
"@platforms//os:windows",
500-
"@platforms//cpu:{}".format(cpu),
501-
],
502-
want_abis = [],
503-
platform_tags = platform_tags,
504-
env = {
505-
"platform_version": "0",
506-
},
507-
)
508-
509428
def parse_modules(
510429
module_ctx,
511430
_fail = fail,
@@ -560,7 +479,6 @@ You cannot use both the additive_build_content and additive_build_content_file a
560479
"enable_pipstar": enable_pipstar,
561480
"platforms": {},
562481
}
563-
_set_defaults(defaults)
564482
for mod in module_ctx.modules:
565483
if not (mod.is_root or mod.name == "rules_python"):
566484
continue

0 commit comments

Comments
 (0)