Skip to content

Commit e75473a

Browse files
authored
Replace url_override with base_url (#43)
In practice, this is the only part we need to replace, the actual file name stays the same. It also helps with simplifying the wheel unpacking logic in modular/modular, as we can reuse this value in more places, and override it all in one place.
1 parent 5d9057d commit e75473a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

mojo/extensions.bzl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ _NULL_SHAS = {
2929
}
3030

3131
def _mojo_toolchain_impl(rctx):
32+
base_url = rctx.attr.base_url or "https://dl.modular.com/public/nightly/python"
3233
rctx.download_and_extract(
33-
url = rctx.attr.url_override or "https://dl.modular.com/public/nightly/python/max-{}-py3-none-{}.whl".format(
34+
url = "{}/max-{}-py3-none-{}.whl".format(
35+
base_url,
3436
rctx.attr.version,
3537
_PLATFORM_MAPPINGS[rctx.attr.platform],
3638
),
@@ -60,8 +62,8 @@ _mojo_toolchain_repository = repository_rule(
6062
values = _PLATFORMS,
6163
mandatory = True,
6264
),
63-
"url_override": attr.string(
64-
doc = "Override the download URL for the prebuilt package.",
65+
"base_url": attr.string(
66+
doc = "Override the base download URL for the prebuilt package.",
6567
default = "",
6668
),
6769
"use_prebuilt_packages": attr.bool(
@@ -115,7 +117,7 @@ def _setup_toolchains(root_module, rules_mojo_module):
115117
name = name,
116118
version = tags.version,
117119
platform = platform,
118-
url_override = tags.url_override,
120+
base_url = tags.base_url,
119121
use_prebuilt_packages = tags.use_prebuilt_packages,
120122
)
121123

@@ -165,8 +167,8 @@ _toolchain_tag = tag_class(
165167
doc = "The version of the Mojo toolchain to download.",
166168
default = _DEFAULT_VERSION,
167169
),
168-
"url_override": attr.string(
169-
doc = "Override the download URL for the prebuilt package.",
170+
"base_url": attr.string(
171+
doc = "Override the base download URL for the prebuilt package.",
170172
default = "",
171173
),
172174
"use_prebuilt_packages": attr.bool(

0 commit comments

Comments
 (0)