rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

Support Windows on ARM64

Open skeptic-monkey opened this issue 1 year ago • 1 comments

🚀 feature request

Relevant Rules

Mostly all the rules included in bazelbuild/rules_python repository (hermetic python toolchain, pip_parse, ...)

Description

There is currently no support to build natively for Windows / ARM64 platform which is not convenient. The Snapdragon X being used in popular laptops (surface pro for example), it now becomes quite important to be able to build for this platform natively.

Describe the solution you'd like

The ideal would be to download an arm64 version of python and use arm64 pip requirements (and per architecture requirement seem to be already supported).

Describe alternatives you've considered

A workaround would already to support building using an hermetic x86_64 python with x86_64 pip dependencies while using an arm64 host, relying on the x96_64 -> arm64 Windows emulation.

This doesn't work either, because pip_parse discards the x86_64 dependencies because it doesn't match the host cpu.

skeptic-monkey avatar Oct 07 '24 15:10 skeptic-monkey

I don't think I see Windows ARM64 interpreter builds for indygreg even in the latest release, hence I am not sure if that is something that rules_python has to provide.

Given that users can build their own Python interpreter and register it as a toolchain and use the pip parse rules to pull the dependencies (pending the work as part of #260, still experimental but in #2278 becomes one step closer to stabilization), I am inclined to close this as won't do.

Once indygreg provides builds for Windows ARM64 interpreter, we can add them as part of regular maintenance tasks.

aignas avatar Oct 09 '24 09:10 aignas

It seems that indygreg might support it soon. see https://github.com/indygreg/python-build-standalone/issues/386

skeptic-monkey avatar Nov 04 '24 19:11 skeptic-monkey

So since the interpreter bits have landed, it would be great if someone with time and such machine could step up to contribute to iron out the remaining issues.

aignas avatar Jul 18 '25 00:07 aignas

We do have windows arm64 machines. I'll give it a try.

skeptic-monkey avatar Jul 18 '25 07:07 skeptic-monkey

FYI, the bzlmod support for experimental_index_url feature will be easier to add once #3058 is merged.

aignas avatar Jul 18 '25 09:07 aignas

While working on bazel-contrib/rules_scala#1761, I used the following patch to use rules_python 1.5.3 successfully on Windows ARM64:

diff --git a/examples/crossbuild/MODULE.bazel b/examples/crossbuild/MODULE.bazel
index cedb0731..668bf4b0 100644
--- a/examples/crossbuild/MODULE.bazel
+++ b/examples/crossbuild/MODULE.bazel
@@ -64,3 +64,20 @@ single_version_override(
     patches = ["//:protobuf.patch"],
     version = "32.0",
 )
+
+bazel_dep(name = "rules_python", version = "1.5.3", dev_dependency = True)
+
+python = use_extension(
+    "@rules_python//python/extensions:python.bzl",
+    "python",
+    dev_dependency = True,
+)
+python.toolchain(python_version = "3.11.13")
+python.single_version_platform_override(
+    platform = "aarch64-pc-windows-msvc",
+    sha256 = "61187f99352429e8f87fb305a8b995c8cf5b70509c59b409dc80787148920e66",
+    python_version = "3.11.13",
+    urls = [
+        "20250818/cpython-{python_version}+20250818-{platform}-{build}.{ext}",
+    ],
+)

It'd be lovely to have the Windows ARM64 builds available in rules_python v1.5.4 to render this patch unnecessary. 🙂

mbland avatar Aug 21 '25 15:08 mbland

While working on bazel-contrib/rules_scala#1761, I used the following patch to use rules_python 1.5.3 successfully on Windows ARM64:

diff --git a/examples/crossbuild/MODULE.bazel b/examples/crossbuild/MODULE.bazel index cedb0731..668bf4b0 100644 --- a/examples/crossbuild/MODULE.bazel +++ b/examples/crossbuild/MODULE.bazel @@ -64,3 +64,20 @@ single_version_override( patches = ["//:protobuf.patch"], version = "32.0", ) + +bazel_dep(name = "rules_python", version = "1.5.3", dev_dependency = True) + +python = use_extension(

  • "@rules_python//python/extensions:python.bzl",
  • "python",
  • dev_dependency = True, +) +python.toolchain(python_version = "3.11.13") +python.single_version_platform_override(
  • platform = "aarch64-pc-windows-msvc",
  • sha256 = "61187f99352429e8f87fb305a8b995c8cf5b70509c59b409dc80787148920e66",
  • python_version = "3.11.13",
  • urls = [
  •    "20250818/cpython-{python_version}+20250818-{platform}-{build}.{ext}",
    
  • ], +) It'd be lovely to have the Windows ARM64 builds available in rules_python v1.5.4 to render this patch unnecessary. 🙂

Can confirm this worked me as well. +1 on the support in v1.5.4.

int5-grey avatar Aug 21 '25 20:08 int5-grey

v1.5.4 scope should only include bug fixes and lack of ARM64 support on Windows is not a bug. Whoever is interested in arm64 support in 1.6.0 (I think I'd be OK to still include it), please create a PR to the main branch and comment in the #3188 issue.

aignas avatar Aug 25 '25 04:08 aignas

Yeah, I should've said 1.6.0. But it seems aarch64-pc-windows-msvc build support already landed in 1.6.0-rc0, including the changes from #3116.

Indeed, I just built successfully on my Windows ARM64 setup with the following (without python.single_version_platform_override):

bazel_dep(name = "rules_python", version = "1.6.0-rc0", dev_dependency = True)

python = use_extension(
    "@rules_python//python/extensions:python.bzl",
    "python",
    dev_dependency = True,
)
python.toolchain(python_version = "3.11.13")

mbland avatar Aug 25 '25 16:08 mbland