Skip to content

Commit 44f92aa

Browse files
authored
Update paths to py_utils and repo_utils in local_python_runtime
1 parent db3300a commit 44f92aa

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

bazel/repo_rules/local_python_runtime.bzl

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ and @rules_python/python/private/local_runtime_repo.bzl
3232
"""
3333

3434
load(
35-
"//bazel/repo_rules:py_utils.bzl",
35+
"//third_party/tensorstore/opensource_only/bazel/repo_rules:py_utils.bzl",
3636
"py_utils",
3737
_ENV_VARS = "ENV_VARS",
3838
)
3939
load(
40-
"//bazel/repo_rules:repo_utils.bzl",
40+
"//third_party/tensorstore/opensource_only/bazel/repo_rules:repo_utils.bzl",
4141
"repo_utils",
4242
)
4343

@@ -86,13 +86,12 @@ def _expand_incompatible_template():
8686
abi3_libraries = "[]",
8787
)
8888

89-
def _symlink_libraries(rctx, logger, subdir, libraries, shlib_suffix):
89+
def _symlink_libraries(rctx, logger, libraries, shlib_suffix):
9090
"""Symlinks the shared libraries into the lib/ directory.
9191
9292
Args:
9393
rctx: A repository_ctx object
9494
logger: A repo_utils.logger object
95-
subdir: The subdirectory to symlink to. e.g. "lib"
9695
libraries: paths to libraries to attempt to symlink.
9796
shlib_suffix: Optional. Ensure that the generated symlinks end with this suffix.
9897
Returns:
@@ -112,9 +111,9 @@ def _symlink_libraries(rctx, logger, subdir, libraries, shlib_suffix):
112111
# of the runtime installation.
113112
continue
114113
if shlib_suffix and not origin.basename.endswith(shlib_suffix):
115-
target = "{}/{}{}".format(subdir, origin.basename, shlib_suffix)
114+
target = "lib/{}{}".format(origin.basename, shlib_suffix)
116115
else:
117-
target = "{}/{}".format(subdir, origin.basename)
116+
target = "lib/{}".format(origin.basename)
118117
logger.debug(lambda: "Symlinking {} to {}".format(origin, target))
119118
repo_utils.watch(rctx, origin)
120119
rctx.symlink(origin, target)
@@ -197,31 +196,30 @@ def _local_python_repo_impl(rctx):
197196
rctx.symlink(include_path, "include")
198197

199198
rctx.report_progress("Symlinking external Python shared libraries")
199+
additional_dlls = _symlink_libraries(rctx, logger, info["additional_dlls"], None)
200200

201201
interface_library = None
202-
libraries = _symlink_libraries(rctx, logger, "lib", info["dynamic_libraries"], info["shlib_suffix"])
202+
libraries = _symlink_libraries(rctx, logger, info["dynamic_libraries"], info["shlib_suffix"])
203203
if libraries:
204-
symlinked = _symlink_libraries(rctx, logger, "lib", info["interface_libraries"], None)
204+
libraries.extend(additional_dlls)
205+
symlinked = _symlink_libraries(rctx, logger, info["interface_libraries"], None)
205206
if symlinked:
206207
interface_library = symlinked[0]
207208
else:
208-
libraries = _symlink_libraries(rctx, logger, "lib", info["static_libraries"], None)
209+
libraries = _symlink_libraries(rctx, logger, info["static_libraries"], None)
209210
if not libraries:
210211
logger.info("No python libraries found.")
211212

212213
abi3_interface_library = None
213-
abi3_libraries = _symlink_libraries(rctx, logger, "lib", info["abi_dynamic_libraries"], info["shlib_suffix"])
214+
abi3_libraries = _symlink_libraries(rctx, logger, info["abi_dynamic_libraries"], info["shlib_suffix"])
214215
if abi3_libraries:
215-
symlinked = _symlink_libraries(rctx, logger, "lib", info["abi_interface_libraries"], None)
216+
abi3_libraries.extend(additional_dlls)
217+
symlinked = _symlink_libraries(rctx, logger, info["abi_interface_libraries"], None)
216218
if symlinked:
217219
abi3_interface_library = symlinked[0]
218220
else:
219221
logger.info("No abi3 python libraries found.")
220222

221-
# On Windows, we need to link to the additional DLLs.
222-
if info["additional_dlls"]:
223-
_symlink_libraries(rctx, logger, "dlls", info["additional_dlls"], None)
224-
225223
os_name = repo_utils.get_platforms_os_name(rctx)
226224

227225
build_bazel = _TOOLCHAIN_IMPL_TEMPLATE.format(
@@ -277,7 +275,7 @@ How to handle errors when trying to automatically determine settings.
277275
),
278276
"_get_runtime_info": attr.label(
279277
allow_single_file = True,
280-
default = Label("//bazel/repo_rules:get_local_runtime_info.py"),
278+
default = Label("//third_party/tensorstore/opensource_only/bazel/repo_rules:get_local_runtime_info.py"),
281279
),
282280
}
283281

0 commit comments

Comments
 (0)