Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ensure_rust_toolchain to buildall #83

Merged
merged 6 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions pyodide_build/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from pyodide_build.recipe import load_all_recipes

RUST_BUILD_PRELUDE = """
rustup toolchain install ${RUST_TOOLCHAIN} && rustup default ${RUST_TOOLCHAIN}
rustup target add wasm32-unknown-emscripten --toolchain ${RUST_TOOLCHAIN}
rustup default ${RUST_TOOLCHAIN}
Copy link
Member Author

Choose a reason for hiding this comment

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

I suppose we could also do this in _ensure_rust_toolchain() and remove RUST_BUILD_PRELUDE entirely.

Copy link
Member

Choose a reason for hiding this comment

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

Then , will pyodide build-recipes-no-deps work?

"""


Expand Down
29 changes: 29 additions & 0 deletions pyodide_build/buildall.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from pyodide_build.build_env import BuildArgs
from pyodide_build.buildpkg import needs_rebuild
from pyodide_build.common import (
exit_with_stdio,
extract_wheel_metadata_file,
find_matching_wheels,
find_missing_executables,
Expand Down Expand Up @@ -645,6 +646,28 @@ def run(self, n_jobs: int, already_built: set[str]) -> None:
self.build_queue.put((job_priority(dependent), dependent))


def _ensure_rust_toolchain():
rust_toolchain = build_env.get_build_flag("RUST_TOOLCHAIN")
result = subprocess.run(
["rustup", "toolchain", "install", rust_toolchain], check=False
)
if result.returncode == 0:
result = subprocess.run(
[
"rustup",
"target",
"add",
"wasm32-unknown-emscripten",
"--toolchain",
rust_toolchain,
],
check=False,
)
if result.returncode != 0:
logger.error("ERROR: rustup toolchain install failed")
exit_with_stdio(result)


def build_from_graph(
pkg_map: dict[str, BasePackage],
build_args: BuildArgs,
Expand Down Expand Up @@ -686,6 +709,12 @@ def build_from_graph(
for pkg_name in needs_build:
pkg_map[pkg_name].unbuilt_host_dependencies.difference_update(already_built)

needs_rust = any(
pkg_map[pkg_name].meta.is_rust_package() for pkg_name in needs_build
)
if needs_rust:
_ensure_rust_toolchain()

if already_built:
logger.info(
"The following packages are already built: [bold]%s[/bold]",
Expand Down
Loading