Skip to content

Commit 3b5c2b7

Browse files
authored
Update to new wheel structure (#79)
mojo-compiler got split into two wheels, one just contains the .mojopkg files. Also update various tests to reflect recent changes.
1 parent b2a2947 commit 3b5c2b7

File tree

8 files changed

+43
-40
lines changed

8 files changed

+43
-40
lines changed

mojo/extensions.bzl

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ load("//mojo:mojo_host_platform.bzl", "mojo_host_platform")
44
load("//mojo/private:mojo_gpu_toolchains_repository.bzl", "mojo_gpu_toolchains_repository")
55

66
_PLATFORMS = ["linux_aarch64", "linux_x86_64", "macos_arm64"]
7-
_DEFAULT_VERSION = "0.26.2.0.dev2026012806"
7+
_DEFAULT_VERSION = "0.26.3.0.dev2026031105"
88
_KNOWN_SHAS = {
9-
"0.26.1.0.dev2026011405": {
10-
"linux_aarch64": "f365b74545234d891f76db0395dfcfc41eb4591a611d361251738ba197d8281b",
11-
"linux_x86_64": "4f0f0aa0eb6c815cd081c76a8218865a3d22d0a33fa502245d41e1a6ad836a15",
12-
"macos_arm64": "0ea255379d009779e6a3ccda7039146f33cdd15324c3e97d659a6fb1644f2519",
13-
},
14-
"0.26.2.0.dev2026012806": {
15-
"linux_aarch64": "1883a67311f8f51c17869c81b93014153215afff078aee0da454823400ecb218",
16-
"linux_x86_64": "91f88e2fd9b4c612f9c08da95cfcb9a4a1291f603c95314f35ed6366736f01c6",
17-
"macos_arm64": "ba37e525b6ba6a7e4a70a8bbef83bce1187541a2d4da625943c3a604d69b261c",
9+
"0.26.3.0.dev2026031105": {
10+
"linux_aarch64": "a62136e7d0bd0a44bc0d0b62e6179180d721c99c7308fd4c666885c37f43740e",
11+
"linux_x86_64": "acf1777039b79c9f75e814ca0124ab913c02a68a4f4bb919e6fed183fa2f2602",
12+
"macos_arm64": "50b994a44fa52f2487e81e288dbb2e417da7132fffe0e908a2e3a1ec9418e42e",
13+
"mojo_compiler_mojo_libs": "32fb42e57af02309f35b668c0e4eb78fc87d0459165dca0a10223ab6d37a5cb3",
1814
},
1915
}
2016
_PLATFORM_MAPPINGS = {
@@ -26,20 +22,25 @@ _NULL_SHAS = {
2622
"linux_aarch64": "",
2723
"linux_x86_64": "",
2824
"macos_arm64": "",
25+
"mojo_compiler_mojo_libs": "",
2926
}
3027

3128
def _mojo_toolchain_impl(rctx):
32-
base_url = rctx.attr.base_url or "https://whl.modular.com/nightly/mojo-compiler"
33-
rctx.download_and_extract(
34-
url = "{}/mojo_compiler-{}-py3-none-{}.whl".format(
35-
base_url,
36-
rctx.attr.version,
37-
_PLATFORM_MAPPINGS[rctx.attr.platform],
38-
),
39-
sha256 = _KNOWN_SHAS.get(rctx.attr.version, _NULL_SHAS)[rctx.attr.platform],
40-
type = "zip",
41-
strip_prefix = "mojo_compiler-{}.data/platlib/modular".format(rctx.attr.version),
42-
)
29+
for whl in "mojo_compiler", "mojo_compiler_mojo_libs":
30+
base_url = (rctx.attr.base_url or "https://whl.modular.com/nightly/") + whl.replace("_", "-")
31+
platform = _PLATFORM_MAPPINGS[rctx.attr.platform] if whl == "mojo_compiler" else "any"
32+
sha_key = rctx.attr.platform if whl == "mojo_compiler" else "mojo_compiler_mojo_libs"
33+
rctx.download_and_extract(
34+
url = "{}/{}-{}-py3-none-{}.whl".format(
35+
base_url,
36+
whl,
37+
rctx.attr.version,
38+
platform,
39+
),
40+
sha256 = _KNOWN_SHAS.get(rctx.attr.version, _NULL_SHAS)[sha_key],
41+
type = "zip",
42+
strip_prefix = "{}-{}.data/platlib/modular".format(whl, rctx.attr.version),
43+
)
4344

4445
rctx.template(
4546
"BUILD.bazel",

tests/cc/cc_test.mojo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from sys import external_call
1+
from std.ffi import external_call
22

33
fn main() raises:
44
external_call["foo", NoneType]()

tests/hello_world_test.mojo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from testing import assert_equal
1+
from std.testing import assert_equal
22
from package.package import foo
33

44

tests/python/basic_python_test.mojo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from python import Python
2-
from os import getenv
3-
from testing import assert_true
1+
from std.python import Python
2+
from std.os import getenv
3+
from std.testing import assert_true
44

5-
def main():
5+
def main() raises:
66
sys = Python.import_module("sys")
77
print("Python executable:", sys.executable)
88
print("Python version:", sys.version)

tests/python/deps_python_test.mojo

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from python import Python
2-
from testing import assert_equal
3-
import os
4-
import subprocess
1+
from std.python import Python
2+
from std.testing import assert_equal
3+
import std.os
4+
import std.subprocess
55

6-
def test_basic_numpy_example():
6+
def test_basic_numpy_example() raises:
77
var np = Python.import_module("numpy")
88
var array = np.array(
99
Python.list(
@@ -14,5 +14,5 @@ def test_basic_numpy_example():
1414
assert_equal(String(array.shape), "(2, 3)")
1515

1616

17-
def main():
17+
def main() raises:
1818
test_basic_numpy_example()

tests/python/python_shared_library.mojo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from os import abort
1+
from std.os import abort
22

3-
from python import Python, PythonObject
4-
from python.bindings import PythonModuleBuilder
5-
from python._cpython import PyObjectPtr
3+
from std.python import Python, PythonObject
4+
from std.python.bindings import PythonModuleBuilder
5+
from std.python._cpython import PyObjectPtr
66

77

88
@export

tests/shared_library_test.mojo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from sys.ffi import c_int, external_call
2-
from testing import assert_equal
1+
from std.ffi import c_int, external_call
2+
from std.testing import assert_equal
33

4-
def main():
4+
def main() raises:
55
print("Calling external function...")
66
result = external_call["foo", c_int]()
77
print("Result from external function:", result)

tools/getshas.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ directory=$(mktemp -d)
1717
curl --location --fail --output "$directory/linux_x86_64" "https://whl.modular.com/nightly/mojo-compiler/mojo_compiler-$version-py3-none-manylinux_2_34_x86_64.whl"
1818
curl --location --fail --output "$directory/linux_aarch64" "https://whl.modular.com/nightly/mojo-compiler/mojo_compiler-$version-py3-none-manylinux_2_34_aarch64.whl"
1919
curl --location --fail --output "$directory/macos" "https://whl.modular.com/nightly/mojo-compiler/mojo_compiler-$version-py3-none-macosx_13_0_arm64.whl"
20+
curl --location --fail --output "$directory/mojo_compiler_mojo_libs" "https://whl.modular.com/nightly/mojo-compiler-mojo-libs/mojo_compiler_mojo_libs-$version-py3-none-any.whl"
2021

2122
cat <<EOF
2223
"$version": {
2324
"linux_aarch64": "$(getsha "$directory/linux_aarch64")",
2425
"linux_x86_64": "$(getsha "$directory/linux_x86_64")",
2526
"macos_arm64": "$(getsha "$directory/macos")",
27+
"mojo_compiler_mojo_libs": "$(getsha "$directory/mojo_compiler_mojo_libs")",
2628
}
2729
EOF

0 commit comments

Comments
 (0)