From 0b79f86236b413badb7ccb297060a43e71079f59 Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 8 Jan 2026 13:57:21 -0700 Subject: [PATCH 01/10] feat(uv): Native actions for crossbuilds --- MODULE.bazel | 4 +- py/private/toolchain/BUILD.bazel | 22 ++++- py/private/toolchain/tools.bzl | 14 +++- py/private/toolchain/types.bzl | 1 + uv/private/extension.bzl | 37 ++++++++- uv/private/sdist_build/build_helper.py | 56 +++++++------ uv/private/sdist_build/repository.bzl | 8 +- uv/private/sdist_build/rule.bzl | 107 +++++++++++++------------ 8 files changed, 164 insertions(+), 85 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index a313205f..c64a6f12 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -27,9 +27,7 @@ use_repo(tools, "rules_py_pex_2_3_1") register_toolchains( "@rules_py_tools//:all", - "@aspect_rules_py//py/private/toolchain/venv/...", - "@aspect_rules_py//py/private/toolchain/unpack/...", - "@aspect_rules_py//py/private/toolchain/shim/...", + "@aspect_rules_py//py/private/toolchain/...", ) toml = use_extension("//uv/private/tomltool:extension.bzl", "tomltool") diff --git a/py/private/toolchain/BUILD.bazel b/py/private/toolchain/BUILD.bazel index f22b5d55..dec73c2b 100644 --- a/py/private/toolchain/BUILD.bazel +++ b/py/private/toolchain/BUILD.bazel @@ -1,5 +1,5 @@ load("@bazel_lib//:bzl_library.bzl", "bzl_library") -load(":tools.bzl", "resolved_unpack_toolchain", "resolved_venv_toolchain") +load(":tools.bzl", "resolved_unpack_toolchain", "resolved_venv_toolchain", "dummy_toolchain") exports_files( ["python.sh"], @@ -31,6 +31,26 @@ resolved_unpack_toolchain( visibility = ["//visibility:public"], ) +# Implementation detail of the target exec toolchain +dummy_toolchain( + name = "empty", + visibility = ["//visibility:private"] +) + +toolchain_type( + name = "target_exec_toolchain_type", +) + +# This creates a toolchain instance with exec_compatible_with placement +# constraints matching the target, backed by the Python toolchain already +# resolved for the target. +toolchain( + name = "target_exec_toolchain", + toolchain_type = "target_exec_toolchain_type", + toolchain = ":empty", + use_target_platform_constraints = True, +) + bzl_library( name = "autodetecting", srcs = ["autodetecting.bzl"], diff --git a/py/private/toolchain/tools.bzl b/py/private/toolchain/tools.bzl index 11d38b4f..3c46ee66 100644 --- a/py/private/toolchain/tools.bzl +++ b/py/private/toolchain/tools.bzl @@ -1,7 +1,7 @@ """Declaration of concrete toolchains for our Rust tools""" load("@bazel_skylib//lib:structs.bzl", "structs") -load(":types.bzl", "PyToolInfo", "UNPACK_TOOLCHAIN", "VENV_TOOLCHAIN") +load(":types.bzl", "PyToolInfo", "UNPACK_TOOLCHAIN", "VENV_TOOLCHAIN", "PY_TOOLCHAIN") def PrebuiltToolConfig( target, @@ -147,3 +147,15 @@ resolved_unpack_toolchain = rule( implementation = _resolved_unpack_impl, toolchains = [UNPACK_TOOLCHAIN], ) + +def _dummy_toolchain_impl(ctx): + toolchain_info = platform_common.ToolchainInfo( + dummy = True, + ) + return [toolchain_info] + +dummy_toolchain = rule( + implementation = _dummy_toolchain_impl, + attrs = { + }, +) diff --git a/py/private/toolchain/types.bzl b/py/private/toolchain/types.bzl index 67848ef3..b9092fbe 100644 --- a/py/private/toolchain/types.bzl +++ b/py/private/toolchain/types.bzl @@ -7,6 +7,7 @@ SH_TOOLCHAIN = "@bazel_tools//tools/sh:toolchain_type" SHIM_TOOLCHAIN = "@aspect_rules_py//py/private/toolchain:shim_toolchain_type" UNPACK_TOOLCHAIN = "@aspect_rules_py//py/private/toolchain:unpack_toolchain_type" VENV_TOOLCHAIN = "@aspect_rules_py//py/private/toolchain:venv_toolchain_type" +TARGET_EXEC_TOOLCHAIN = "@aspect_rules_py//py/private/toolchain:target_exec_toolchain_type" PyToolInfo = provider( doc = "An info so we don't just return bare files", diff --git a/uv/private/extension.bzl b/uv/private/extension.bzl index e1ce6eb5..219a19a4 100644 --- a/uv/private/extension.bzl +++ b/uv/private/extension.bzl @@ -257,10 +257,20 @@ def _parse_annotations(module_ctx, hub_specs, venv_specs): Dep = TypedDict({"name": str}) record( - per_package=Dict[str, List[Dep]], + per_package=Dict[str, Annotation], default_build_deps=List[Dep], ) + The annotations file is structured as follows: + + ``` + version = 0.0.0 + [[package]] + name = "foo" + native = true + build-dependencies = [ {name = "bar"} ] + ``` + Args: module_ctx (module_ctx): The Bazel module context hub_specs (dict): The previously parsed hub specs @@ -543,7 +553,29 @@ def _sbuild_repos(_module_ctx, lock_specs, annotation_specs, override_specs): for it in build_deps + venv_anns.default_build_deps } - # print("Creating sdist repo", name) + # TODO: Need a better native strategy. + # + # We need to decide if the sdist we're building contains native + # extensions. For now we're relying on user-provided annotations + # to do that. + # + # It would be better for the sdist_build repo rule to inspect + # the sdist's contents and search for well known file types such + # as `pyx` and `cxx`. That would also make it easier to support + # for instance Rust extensions. This would work from a phasing + # perspective because we declare sdist archives separately, so + # the repo rule for deciding whether an sdist build is native or + # not can run (prebuilt) tools to inspect downloaded archives. + is_native = ( + # Cythonized code + "cython" in build_deps or + # Mypyc code + "mypy" in build_deps or + # User has annotated the package as using C extensions or such + venv_anns.per_package.get(package["name"], {}).get("native", False) + ) + + # TODO: What if the build needs toolchains? (cc, etc.) sdist_build( name = name, src = "@" + _sdist_repo_name(package) + "//file", @@ -552,6 +584,7 @@ def _sbuild_repos(_module_ctx, lock_specs, annotation_specs, override_specs): "@" + _venv_target(hub_name, venv_name, package["name"]) for package in build_deps.values() ], + is_native = is_native, ) def _whl_install_repo_name(hub, venv, package): diff --git a/uv/private/sdist_build/build_helper.py b/uv/private/sdist_build/build_helper.py index d92c0cae..66559c11 100644 --- a/uv/private/sdist_build/build_helper.py +++ b/uv/private/sdist_build/build_helper.py @@ -1,40 +1,46 @@ #!/usr/bin/env python3 +""" +A minimal python3 -m build wrapper + +Mostly exists to allow debugging +""" + from argparse import ArgumentParser import shutil import sys from os import getenv, listdir, path -from subprocess import call - -# Under Bazel, the source dir of a sdist to build is immutable. `build` and -# other tools however are constitutionally incapable of not writing to the -# source tree. -# -# As a workaround, we use this launcher which exists to do two things. -# - It makes a writable tempdir with a copy of the source tree -# - It punts to `build` targeting the tempdir - -print(sys.executable, file=sys.stderr) +from subprocess import check_call +from tempfile import TemporaryDirectory PARSER = ArgumentParser() -PARSER.add_argument("srcdir") +PARSER.add_argument("srcarchive") PARSER.add_argument("outdir") +PARSER.add_argument("--validate-anyarch", action="store_true") +PARSER.add_argument("--sandbox", action="store_true") opts, args = PARSER.parse_known_args() -t = getenv("TMPDIR") # Provided by Bazel +with TemporaryDirectory() as t: + # Extract the source archive + shutil.unpack_archive(opts.srcarchive, t) + + # Get a path to the outdir which will be valid after we cd + outdir = path.abspath(opts.outdir) -# Dirty awful way to prevent permissions from being replicated -shutil.copystat = lambda x, y, **k: None -shutil.copytree(opts.srcdir, t, dirs_exist_ok=True) + check_call([ + sys.executable, + "-m", "build", + "--wheel", + "--no-isolation", + "--outdir", outdir, + ], cwd=t) -outdir = path.abspath(opts.outdir) + inventory = listdir(outdir) -call([ - sys.executable, - "-m", "build", - "--wheel", - "--no-isolation", - "--outdir", outdir, -], cwd=t) + if len(inventory) > 1: + print("Error: Built more than one wheel!", file=sys.stderr) + exit(1) -print(listdir(outdir), file=sys.stderr) + if opts.validate_anyarch and not inventory[0].endswith("-none-any.whl"): + print("Error: Target was anyarch but built a none-any wheel!") + exit(1) diff --git a/uv/private/sdist_build/repository.bzl b/uv/private/sdist_build/repository.bzl index 2f2845f9..ea5dba63 100644 --- a/uv/private/sdist_build/repository.bzl +++ b/uv/private/sdist_build/repository.bzl @@ -8,7 +8,7 @@ sibling `rule.bzl` file for the implementation of `sdist_build`. def _sdist_build_impl(repository_ctx): repository_ctx.file("BUILD.bazel", content = """ -load("@aspect_rules_py//uv/private/sdist_build:rule.bzl", "sdist_build") +load("@aspect_rules_py//uv/private/sdist_build:rule.bzl", "{rule}") load("@aspect_rules_py//py/unstable:defs.bzl", "py_venv") py_venv( @@ -16,15 +16,18 @@ py_venv( deps = {deps}, ) -sdist_build( +{rule}( name = "whl", src = "{src}", venv = ":build_venv", + args = [], visibility = ["//visibility:public"], ) """.format( src = repository_ctx.attr.src, deps = repr([str(it) for it in repository_ctx.attr.deps]), + # FIXME: This should probably be inferred by looking at the inventory of the sdist + rule = "sdist_native_build" if repository_ctx.attr.is_native else "sdist_build", )) sdist_build = repository_rule( @@ -32,5 +35,6 @@ sdist_build = repository_rule( attrs = { "src": attr.label(), "deps": attr.label_list(), + "is_native": attr.bool(), }, ) diff --git a/uv/private/sdist_build/rule.bzl b/uv/private/sdist_build/rule.bzl index 1a23a028..2dd69189 100644 --- a/uv/private/sdist_build/rule.bzl +++ b/uv/private/sdist_build/rule.bzl @@ -5,41 +5,17 @@ Actually building sdists. load("//py/private/py_venv:types.bzl", "VirtualenvInfo") # buildifier: disable=bzl-visibility -load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN") +load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "TARGET_EXEC_TOOLCHAIN") load("//uv/private:defs.bzl", "lib_mode_transition") -TAR_TOOLCHAIN = "@tar.bzl//tar/toolchain:type" # UV_TOOLCHAIN = "@multitool//tools/uv:toolchain_type" def _sdist_build(ctx): - py_toolchain = ctx.toolchains[PY_TOOLCHAIN].py3_runtime - tar = ctx.toolchains[TAR_TOOLCHAIN] + py_toolchain = ctx.exec_groups["target"].toolchains[PY_TOOLCHAIN].py3_runtime # uv = ctx.toolchains[UV_TOOLCHAIN] - unpacked_sdist = ctx.actions.declare_directory( - "src", - ) - archive = ctx.attr.src[DefaultInfo].files.to_list()[0] - # Extract the archive - ctx.actions.run( - executable = tar.tarinfo.binary, - arguments = [ - "--strip-components=1", # Ditch archive leader - "-xf", - archive.path, - "-C", - unpacked_sdist.path, - ], - inputs = [ - archive, - ] + tar.default.files.to_list(), - outputs = [ - unpacked_sdist, - ], - ) - # Now we need to do a build from the archive dir to a source artifact. wheel_dir = ctx.actions.declare_directory( "build", @@ -54,23 +30,28 @@ def _sdist_build(ctx): # 3. `uv build` which works generally but causes our venv shim to really struggle # # We're going with #1 for now. - # - # TODO: Figure out a way to provide defaults for build and its deps if the user doesn't. + + # Note that we have to use exec_group = "target" to force this action to + # inherit RBE placement properties matching the target platform so that + # it'll run remotely. ctx.actions.run( executable = venv[VirtualenvInfo].home.path + "/bin/python3", arguments = [ - ctx.file._helper.path, - unpacked_sdist.path, + ctx._helper.path + ] + ctx.attr.args + [ + archive.path, wheel_dir.path, ], + # FIXME: Shouldn't need to add the Python toolchain files explictily here; should be transitives/defaultinfo of the venv. inputs = [ - unpacked_sdist, + archive, venv[VirtualenvInfo].home, ctx.file._helper, ] + py_toolchain.files.to_list() + ctx.attr.venv[DefaultInfo].files.to_list(), outputs = [ wheel_dir, ], + exec_group = "target", ) return [ @@ -83,33 +64,57 @@ def _sdist_build(ctx): sdist_build = rule( implementation = _sdist_build, - doc = """Sdist to whl build rule. + doc = """Sdist to _anyarch_ whl build rule. Consumes a sdist artifact and performs a build of that artifact with the specified Python dependencies under the configured Python toochain. """, attrs = { - "src": attr.label(doc = ""), - "venv": attr.label(doc = ""), + "src": attr.label(), + "venv": attr.label(), + "args": attr.string_list(default=["--validate-anyarch"]), "_helper": attr.label(allow_single_file = True, default = Label(":build_helper.py")), }, - toolchains = [ - # TODO: Py toolchain needs to be in the `host` configuration, not the - # `exec` configuration. May need to split toolchains or use a different - # one here. Ditto for the other tools. - PY_TOOLCHAIN, - TAR_TOOLCHAIN, - # UV_TOOLCHAIN, - # FIXME: Add in a cc toolchain here - ], - # KLUDGE: Reset the uv lib mode and force it to lib. This ensures that if - # the user requests a library graph as whl files instead of libraries AND we - # have to do an sdist build to create one of those whls, the sdist builds - # required to produce those whls will occur with their dependencies - # _installed as libraries_ rather than _present as whl files_. - # - # Otherwise the transitive deps of the venv will still be in whl mode and we - # get cool errors that `build` and other tools aren't installed. + exec_groups = { + # Copy-paste from above, but without the target constraint toolchain + "target": exec_group( + toolchains = [ + PY_TOOLCHAIN, + ], + ), + }, + cfg = lib_mode_transition, +) + +sdist_native_build = rule( + implementation = _sdist_build, + doc = """Sdist to whl build rule. + +Consumes a sdist artifact and performs a build of that artifact with the +specified Python dependencies under the configured Python toochain to produce a +platform-specific bdist we can subsequently install or deploy. + +The build is guaranteed to occur on an execution platform matching the +constraints of the target platform. + +""", + attrs = { + "src": attr.label(), + "venv": attr.label(), + "args": attr.string_list(), + "_helper": attr.label(allow_single_file = True, default = Label(":build_helper.py")), + }, + exec_groups = { + # Create an exec group which depends on a toolchain which can only be + # resolved to exec_compatible_with constraints equal to the target. This + # allows us to discover what those constraints need to be. + "target": exec_group( + toolchains = [ + PY_TOOLCHAIN, + TARGET_EXEC_TOOLCHAIN, + ], + ), + }, cfg = lib_mode_transition, ) From 3e7cb771e91d01beb61a142e4d724705221756aa Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 8 Jan 2026 13:57:39 -0700 Subject: [PATCH 02/10] lint: heredoc --- uv/private/whl_install/rule.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uv/private/whl_install/rule.bzl b/uv/private/whl_install/rule.bzl index 8e22bec0..a4798d54 100644 --- a/uv/private/whl_install/rule.bzl +++ b/uv/private/whl_install/rule.bzl @@ -1,5 +1,5 @@ -"" -"" +""" +""" load("@rules_python//python:defs.bzl", "PyInfo") load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "UNPACK_TOOLCHAIN") From 2d7516b061b0c9d8c4d953805d294bbfa5bc1b4c Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 8 Jan 2026 14:18:27 -0700 Subject: [PATCH 03/10] todo --- e2e/MODULE.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e/MODULE.bazel b/e2e/MODULE.bazel index 6687fa4b..33678bec 100644 --- a/e2e/MODULE.bazel +++ b/e2e/MODULE.bazel @@ -16,6 +16,7 @@ local_path_override( path = "..", ) +# FIXME: Can we clean this up now that sdist builds don't use tar bazel_lib_toolchains = use_extension("@tar.bzl//tar:extensions.bzl", "toolchains", dev_dependency = True) use_repo(bazel_lib_toolchains, "bsd_tar_toolchains") From afe17bdad23b62572c134236797c2b3eb0eda3b7 Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 8 Jan 2026 14:23:01 -0700 Subject: [PATCH 04/10] [NO TESTS] WIP --- uv/private/sdist_build/rule.bzl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/uv/private/sdist_build/rule.bzl b/uv/private/sdist_build/rule.bzl index 2dd69189..39067db7 100644 --- a/uv/private/sdist_build/rule.bzl +++ b/uv/private/sdist_build/rule.bzl @@ -2,14 +2,11 @@ Actually building sdists. """ -load("//py/private/py_venv:types.bzl", "VirtualenvInfo") - # buildifier: disable=bzl-visibility +load("//py/private/py_venv:types.bzl", "VirtualenvInfo") load("//py/private/toolchain:types.bzl", "PY_TOOLCHAIN", "TARGET_EXEC_TOOLCHAIN") load("//uv/private:defs.bzl", "lib_mode_transition") -# UV_TOOLCHAIN = "@multitool//tools/uv:toolchain_type" - def _sdist_build(ctx): py_toolchain = ctx.exec_groups["target"].toolchains[PY_TOOLCHAIN].py3_runtime # uv = ctx.toolchains[UV_TOOLCHAIN] @@ -35,6 +32,8 @@ def _sdist_build(ctx): # inherit RBE placement properties matching the target platform so that # it'll run remotely. ctx.actions.run( + mnemonic = "PySdistBuild", + progress_message = "Source compiling {} to a whl".format(archive.basename), executable = venv[VirtualenvInfo].home.path + "/bin/python3", arguments = [ ctx._helper.path From 11169d86d72f49392c6a7ca3c36ad7b87d049fb5 Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 8 Jan 2026 14:30:48 -0700 Subject: [PATCH 05/10] fix: need to watch toml files --- uv/private/tomltool/toml.bzl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uv/private/tomltool/toml.bzl b/uv/private/tomltool/toml.bzl index 642ad966..bec87d88 100644 --- a/uv/private/tomltool/toml.bzl +++ b/uv/private/tomltool/toml.bzl @@ -58,6 +58,8 @@ def _decode_file(ctx, content_path): os = _translate_os(ctx.os.name) libc = _translate_libc(ctx) + ctx.watch(content_path) + out = ctx.execute( [ Label("@toml2json_{}_{}_{}//file:downloaded".format(arch, os, libc)), From a613c4d3a6a54787f7b2be01d89fc10bfe8e426b Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 8 Jan 2026 14:31:24 -0700 Subject: [PATCH 06/10] fix: ctx.files --- uv/private/sdist_build/rule.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uv/private/sdist_build/rule.bzl b/uv/private/sdist_build/rule.bzl index 39067db7..c9c101ba 100644 --- a/uv/private/sdist_build/rule.bzl +++ b/uv/private/sdist_build/rule.bzl @@ -36,7 +36,7 @@ def _sdist_build(ctx): progress_message = "Source compiling {} to a whl".format(archive.basename), executable = venv[VirtualenvInfo].home.path + "/bin/python3", arguments = [ - ctx._helper.path + ctx.file._helper.path ] + ctx.attr.args + [ archive.path, wheel_dir.path, From c9c233221c996b8ab941b2bf38740a5d6c4a1704 Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 8 Jan 2026 15:00:28 -0700 Subject: [PATCH 07/10] fix: unpack_archive creates a dir --- uv/private/sdist_build/build_helper.py | 32 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/uv/private/sdist_build/build_helper.py b/uv/private/sdist_build/build_helper.py index 66559c11..ef40cf51 100644 --- a/uv/private/sdist_build/build_helper.py +++ b/uv/private/sdist_build/build_helper.py @@ -3,14 +3,14 @@ """ A minimal python3 -m build wrapper -Mostly exists to allow debugging +Mostly exists to allow debugging. """ from argparse import ArgumentParser import shutil import sys -from os import getenv, listdir, path -from subprocess import check_call +from os import listdir, path +from subprocess import CalledProcessError, check_call from tempfile import TemporaryDirectory PARSER = ArgumentParser() @@ -24,23 +24,31 @@ # Extract the source archive shutil.unpack_archive(opts.srcarchive, t) + # Annoyingly, unpack_archive creates a subdir in the target. Update t + # accordingly. Not worth the eng effort to prevent creating this dir. + t = path.join(t, listdir(t)[0]) + # Get a path to the outdir which will be valid after we cd outdir = path.abspath(opts.outdir) - check_call([ - sys.executable, - "-m", "build", - "--wheel", - "--no-isolation", - "--outdir", outdir, - ], cwd=t) + try: + check_call([ + sys.executable, + "-m", "build", + "--wheel", + "--no-isolation", + "--outdir", outdir, + ], cwd=t) + except CalledProcessError: + print("Error: Build failed!\nSee {} for the sandbox".format(t), file=sys.stderr) + exit(1) inventory = listdir(outdir) if len(inventory) > 1: - print("Error: Built more than one wheel!", file=sys.stderr) + print("Error: Built more than one wheel!\nSee {} for the sandbox".format(t), file=sys.stderr) exit(1) if opts.validate_anyarch and not inventory[0].endswith("-none-any.whl"): - print("Error: Target was anyarch but built a none-any wheel!") + print("Error: Target was anyarch but built a none-any wheel!\nSee {} for the sandbox".format(t), file=sys.stderr) exit(1) From f10c88b5c05bd2c3e34404dcf1528e7f6062b664 Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 8 Jan 2026 15:28:35 -0700 Subject: [PATCH 08/10] Put this link back --- e2e/.bazelrc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) mode change 100644 => 120000 e2e/.bazelrc diff --git a/e2e/.bazelrc b/e2e/.bazelrc deleted file mode 100644 index 328e9edd..00000000 --- a/e2e/.bazelrc +++ /dev/null @@ -1,9 +0,0 @@ -common --incompatible_enable_cc_toolchain_resolution -common --@toolchains_llvm_bootstrapped//config:experimental_stub_libgcc_s -common --@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=false - -# Don't try and auto detect the cc toolchain, as we use our own llvm toolchains. -common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 -common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1 - - diff --git a/e2e/.bazelrc b/e2e/.bazelrc new file mode 120000 index 00000000..adb61980 --- /dev/null +++ b/e2e/.bazelrc @@ -0,0 +1 @@ +../.bazelrc \ No newline at end of file From 7a3dbaa56961b08db80f69935dd41a6918267e87 Mon Sep 17 00:00:00 2001 From: "aspect-marvin[bot]" Date: Thu, 8 Jan 2026 22:44:48 +0000 Subject: [PATCH 09/10] Pre-commit changes --- py/private/toolchain/BUILD.bazel | 6 +++--- py/private/toolchain/tools.bzl | 2 +- uv/private/sdist_build/rule.bzl | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/py/private/toolchain/BUILD.bazel b/py/private/toolchain/BUILD.bazel index dec73c2b..e6322e42 100644 --- a/py/private/toolchain/BUILD.bazel +++ b/py/private/toolchain/BUILD.bazel @@ -1,5 +1,5 @@ load("@bazel_lib//:bzl_library.bzl", "bzl_library") -load(":tools.bzl", "resolved_unpack_toolchain", "resolved_venv_toolchain", "dummy_toolchain") +load(":tools.bzl", "dummy_toolchain", "resolved_unpack_toolchain", "resolved_venv_toolchain") exports_files( ["python.sh"], @@ -34,7 +34,7 @@ resolved_unpack_toolchain( # Implementation detail of the target exec toolchain dummy_toolchain( name = "empty", - visibility = ["//visibility:private"] + visibility = ["//visibility:private"], ) toolchain_type( @@ -46,8 +46,8 @@ toolchain_type( # resolved for the target. toolchain( name = "target_exec_toolchain", - toolchain_type = "target_exec_toolchain_type", toolchain = ":empty", + toolchain_type = "target_exec_toolchain_type", use_target_platform_constraints = True, ) diff --git a/py/private/toolchain/tools.bzl b/py/private/toolchain/tools.bzl index 3c46ee66..b2698ddf 100644 --- a/py/private/toolchain/tools.bzl +++ b/py/private/toolchain/tools.bzl @@ -1,7 +1,7 @@ """Declaration of concrete toolchains for our Rust tools""" load("@bazel_skylib//lib:structs.bzl", "structs") -load(":types.bzl", "PyToolInfo", "UNPACK_TOOLCHAIN", "VENV_TOOLCHAIN", "PY_TOOLCHAIN") +load(":types.bzl", "PyToolInfo", "UNPACK_TOOLCHAIN", "VENV_TOOLCHAIN") def PrebuiltToolConfig( target, diff --git a/uv/private/sdist_build/rule.bzl b/uv/private/sdist_build/rule.bzl index c9c101ba..cdd214bf 100644 --- a/uv/private/sdist_build/rule.bzl +++ b/uv/private/sdist_build/rule.bzl @@ -36,12 +36,12 @@ def _sdist_build(ctx): progress_message = "Source compiling {} to a whl".format(archive.basename), executable = venv[VirtualenvInfo].home.path + "/bin/python3", arguments = [ - ctx.file._helper.path + ctx.file._helper.path, ] + ctx.attr.args + [ archive.path, wheel_dir.path, ], - # FIXME: Shouldn't need to add the Python toolchain files explictily here; should be transitives/defaultinfo of the venv. + # FIXME: Shouldn't need to add the Python toolchain files explicitly here; should be transitives/defaultinfo of the venv. inputs = [ archive, venv[VirtualenvInfo].home, @@ -72,7 +72,7 @@ specified Python dependencies under the configured Python toochain. attrs = { "src": attr.label(), "venv": attr.label(), - "args": attr.string_list(default=["--validate-anyarch"]), + "args": attr.string_list(default = ["--validate-anyarch"]), "_helper": attr.label(allow_single_file = True, default = Label(":build_helper.py")), }, exec_groups = { From 2845a235a40afe0f6e23a60f96cdc93626b3c6f8 Mon Sep 17 00:00:00 2001 From: Reid D McKenzie Date: Thu, 15 Jan 2026 13:25:27 -0700 Subject: [PATCH 10/10] [NO TESTS] WIP --- e2e/.bazelrc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) mode change 120000 => 100644 e2e/.bazelrc diff --git a/e2e/.bazelrc b/e2e/.bazelrc deleted file mode 120000 index adb61980..00000000 --- a/e2e/.bazelrc +++ /dev/null @@ -1 +0,0 @@ -../.bazelrc \ No newline at end of file diff --git a/e2e/.bazelrc b/e2e/.bazelrc new file mode 100644 index 00000000..bc72d0e8 --- /dev/null +++ b/e2e/.bazelrc @@ -0,0 +1,10 @@ +common --incompatible_enable_cc_toolchain_resolution +common --@toolchains_llvm_bootstrapped//config:experimental_stub_libgcc_s +common --@rules_cc//cc/toolchains/args/archiver_flags:use_libtool_on_macos=false + +# Don't try and auto detect the cc toolchain, as we use our own llvm toolchains. +common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 +common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1 + +# Configure a default venv +common --@pypi//venv=say