|
15 | 15 | ""
|
16 | 16 |
|
17 | 17 | load("//python:repositories.bzl", "get_interpreter_dirname", "is_standalone_interpreter")
|
| 18 | +load("//python:versions.bzl", "WINDOWS_NAME") |
18 | 19 | load("//python/pip_install:repositories.bzl", "all_requirements")
|
19 | 20 | load("//python/pip_install:requirements_parser.bzl", parse_requirements = "parse")
|
20 | 21 | load("//python/pip_install/private:srcs.bzl", "PIP_INSTALL_PY_SRCS")
|
| 22 | +load("//python/private:toolchains_repo.bzl", "get_host_os_arch") |
21 | 23 |
|
22 | 24 | CPPFLAGS = "CPPFLAGS"
|
23 | 25 |
|
@@ -72,8 +74,16 @@ def _resolve_python_interpreter(rctx):
|
72 | 74 | python_interpreter = _get_python_interpreter_attr(rctx)
|
73 | 75 |
|
74 | 76 | if rctx.attr.python_interpreter_target != None:
|
75 |
| - target = rctx.attr.python_interpreter_target |
76 |
| - python_interpreter = rctx.path(target) |
| 77 | + python_interpreter = rctx.path(rctx.attr.python_interpreter_target) |
| 78 | + |
| 79 | + # If we have @@ we have bzlmod so we need to hand Windows differently. |
| 80 | + if str(Label("//:unused")).startswith("@@"): |
| 81 | + (os, _) = get_host_os_arch(rctx) |
| 82 | + |
| 83 | + # On Windows, the symlink doesn't work because Windows attempts to find |
| 84 | + # Python DLLs where the symlink is, not where the symlink points. |
| 85 | + if os == WINDOWS_NAME: |
| 86 | + python_interpreter = python_interpreter.realpath |
77 | 87 | elif "/" not in python_interpreter:
|
78 | 88 | found_python_interpreter = rctx.which(python_interpreter)
|
79 | 89 | if not found_python_interpreter:
|
@@ -670,7 +680,6 @@ py_binary(
|
670 | 680 |
|
671 | 681 | def _whl_library_impl(rctx):
|
672 | 682 | python_interpreter = _resolve_python_interpreter(rctx)
|
673 |
| - |
674 | 683 | args = [
|
675 | 684 | python_interpreter,
|
676 | 685 | "-m",
|
@@ -699,7 +708,7 @@ def _whl_library_impl(rctx):
|
699 | 708 | )
|
700 | 709 |
|
701 | 710 | if result.return_code:
|
702 |
| - fail("whl_library %s failed: %s (%s)" % (rctx.attr.name, result.stdout, result.stderr)) |
| 711 | + fail("whl_library %s failed: %s (%s) error code: '%s'" % (rctx.attr.name, result.stdout, result.stderr, result.return_code)) |
703 | 712 |
|
704 | 713 | return
|
705 | 714 |
|
|
0 commit comments