When using rules_python 1.8.x with rules_mypy on Windows (Bazel 8.x), whl_library extraction fails

🐞 bug report

Affected Rule

The issue is likely to be caused by the _extract in repo_utils.bzl when called from whl_extract.bzl which in turn is called from whl_library.bzl

Is this a regression?

Yes, the previous version in which this bug was not present was: 1.7.0

Description

When using rules_python 1.8.x with rules_mypy on Windows (Bazel 8.x), whl_library extraction fails to extract packages from rules_mypy requirements.

🔬 Minimal Reproduction

Following repository contains minimum reproduction scenario tested on Windows 11 with Bazel 8.5.1:

https://github.com/vadikmironov/rules_python_1.8.x_repro

🔥 Exception or Error


INFO: Repository rules_python++pip+rules_mypy_pip_312_mypy instantiated at:
  : in 
Repository rule whl_library defined at:
  C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/pypi/whl_library.bzl:689:30: in 
ERROR: C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/repo_utils.bzl:446:18: An error occurred during the fetch of repository 'rules_python++pip+rules_mypy_pip_312_mypy':
   Traceback (most recent call last):
        File "C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/pypi/whl_library.bzl", line 410, column 20, in _whl_library_impl
                whl_extract(rctx, whl_path = whl_path, logger = logger)
        File "C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/pypi/whl_extract.bzl", line 16, column 23, in whl_extract
                repo_utils.extract(
        File "C:/users/user/_bazel_user/rzsptrcq/external/rules_python+/python/private/repo_utils.bzl", line 446, column 18, in _extract
                mrctx.extract(
Error in extract: Cannot write outside of the repository directory for path C:/Users/user/_bazel_user/rzsptrcq/external/rules_python++pip+rules_mypy_pip_312_mypy/site-packages
ERROR: no such package '@@rules_python++pip+rules_mypy_pip_312_mypy//': Cannot write outside of the repository directory for path C:/Users/user/_bazel_user/rzsptrcq/external/rules_python++pip+rules_mypy_pip_312_mypy/site-packages
ERROR: C:/users/user/_bazel_user/rzsptrcq/external/rules_python++pip+rules_mypy_pip/mypy/BUILD.bazel:5:12: @@rules_python++pip+rules_mypy_pip//mypy:pkg depends on @@rules_python++pip+rules_mypy_pip_312_mypy//:pkg in repository @@rules_python++pip+rules_mypy_pip_312_mypy which failed to fetch. no such package '@@rules_python++pip+rules_mypy_pip_312_mypy//': Cannot write outside of the repository directory for path C:/Users/user/_bazel_user/rzsptrcq/external/rules_python++pip+rules_mypy_pip_312_mypy/site-packages
Target //apps:hello failed to build

🌍 Your Environment

Operating System:

  
Windows 11 25H2 26200.7623
  

Output of bazel version:

  
Bazelisk version: v1.28.1
Build label: 8.5.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Mon Jan 12 18:43:11 2026 (1768243391)
Build timestamp: 1768243391
Build timestamp as int: 1768243391
  

Rules_python version:

Anything else relevant?

Works perfectly fine on rules_python 1.7.0. Reviewing the change log following change looks relevant: #3452