Skip to content

Commit 085bc24

Browse files
committed
fix local toolchain
1 parent 5a73954 commit 085bc24

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

python/private/hermetic_runtime_repo_setup.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ def define_hermetic_runtime_toolchain_impl(
243243
# On Windows, a symlink-style venv requires supporting .dll files.
244244
venv_bin_files = select({
245245
"@platforms//os:windows": native.glob(
246-
include = ["*.dll", "*.pdb"],
246+
include = ["*.dll"],
247+
allow_empty = False,
248+
) + native.glob(
249+
include = ["*.pdb"],
247250
allow_empty = True,
248251
),
249252
"//conditions:default": [],

python/private/local_runtime_repo.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ def _norm_path(path):
7474
def _symlink_libraries(rctx, logger, libraries, shlib_suffix):
7575
"""Symlinks the shared libraries into the lib/ directory.
7676
77+
Individual files are symlinked instead of the whole directory because
78+
shared_lib_dirs contains multiple search paths for the shared libraries,
79+
and the python files may be missing from any of those directories, and
80+
any of those directories may include non-python runtime libraries,
81+
as would be the case if LIBDIR were, for example, /usr/lib.
82+
7783
Args:
7884
rctx: A repository_ctx object
7985
logger: A repo_utils.logger object
8086
libraries: paths to libraries to attempt to symlink.
8187
shlib_suffix: Optional. Ensure that the generated symlinks end with this suffix.
8288
Returns:
8389
A list of library paths (under lib/) linked by the action.
84-
85-
Individual files are symlinked instead of the whole directory because
86-
shared_lib_dirs contains multiple search paths for the shared libraries,
87-
and the python files may be missing from any of those directories, and
88-
any of those directories may include non-python runtime libraries,
89-
as would be the case if LIBDIR were, for example, /usr/lib.
9090
"""
9191
result = []
9292
for source in libraries:

python/private/local_runtime_repo_setup.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ def define_local_runtime_toolchain_impl(
153153
implementation_name = implementation_name,
154154
abi_flags = abi_flags,
155155
pyc_tag = "{}-{}{}{}".format(implementation_name, major, minor, abi_flags),
156+
venv_bin_files = select({
157+
"@platforms//os:windows": native.glob(
158+
include = ["lib/*.dll"],
159+
allow_empty = False,
160+
) + native.glob(
161+
include = ["lib/*.pdb"],
162+
allow_empty=True,
163+
),
164+
"//conditions:default": [],
165+
}),
156166
)
157167

158168
py_runtime_pair(

python/private/py_executable.bzl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,16 +723,17 @@ def _create_venv_windows(ctx, *, venv_root, runtime, interpreter_actual_path):
723723
interpreter = ctx.actions.declare_file("{}/{}".format(bin_dir, py_exe_basename))
724724
interpreter_runfiles.add(interpreter)
725725
ctx.actions.symlink(output = interpreter, target_file = runtime.interpreter)
726-
for f in runtime.venv_bin_files:
727-
venv_path = "{}/{}".format(bin_dir, f.basename)
728-
venv_file = ctx.actions.declare_file(venv_path)
729-
ctx.actions.symlink(output = venv_file, target_file = f)
730-
interpreter_runfiles.add(venv_file)
731726
else:
732727
interpreter = ctx.actions.declare_symlink("{}/{}".format(bin_dir, py_exe_basename))
733728
interpreter_runfiles.add(interpreter)
734729
ctx.actions.symlink(output = interpreter, target_path = runtime.interpreter_path)
735730

731+
for f in runtime.venv_bin_files:
732+
venv_path = "{}/{}".format(bin_dir, f.basename)
733+
venv_file = ctx.actions.declare_file(venv_path)
734+
ctx.actions.symlink(output = venv_file, target_file = f)
735+
interpreter_runfiles.add(venv_file)
736+
736737
# See site.py logic: Windows uses a version/build agnostic site-packages path
737738
venv_site_packages = "Lib/site-packages"
738739

python/private/repo_utils.bzl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,19 @@ def _which_unchecked(mrctx, binary_name):
311311
)
312312

313313
def _which_describe_failure(binary_name, path):
314+
if "\\" in path or ";" in path:
315+
path_parts = path.split(";")
316+
else:
317+
path_parts = path.split(":")
318+
for i, v in enumerate(path_parts):
319+
path_parts[i] = " [{}]: {}".format(i, v)
314320
return (
315321
"Unable to find the binary '{binary_name}' on PATH.\n" +
316-
" PATH = {path}"
322+
" PATH entries:\n" +
323+
"{path_str}"
317324
).format(
318325
binary_name = binary_name,
319-
path = path,
326+
path_str = "\n".join(path_parts)
320327
)
321328

322329
def _mkdir(mrctx, path):

0 commit comments

Comments
 (0)