Skip to content

Commit 6f82adf

Browse files
committed
address review comments
1 parent c551343 commit 6f82adf

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

python/private/venv_runfiles.bzl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ def get_venv_symlinks(ctx, files, package, version_str, site_packages_root):
259259
if _is_linker_loaded_library(filename):
260260
entry = VenvSymlinkEntry(
261261
kind = VenvSymlinkKind.LIB,
262-
# todo: omit setting link_to_path
263262
link_to_path = paths.join(runfiles_dir_name, site_packages_root, filename),
264263
link_to_file = src,
265264
package = package,
@@ -297,8 +296,6 @@ def get_venv_symlinks(ctx, files, package, version_str, site_packages_root):
297296
files = depset([src]),
298297
)
299298
venv_symlinks.append(entry)
300-
else:
301-
fail("hit", src)
302299

303300
# Sort so that we encounter `foo` before `foo/bar`. This ensures we
304301
# see the top-most explicit package first.
@@ -336,16 +333,18 @@ def get_venv_symlinks(ctx, files, package, version_str, site_packages_root):
336333
def _is_linker_loaded_library(filename):
337334
"""Tells if a filename is one that `dlopen()` or the runtime linker handles.
338335
339-
This should return true for `libfoo.so` (regular C library), but not
340-
`foo.so` (Python C extension library).
336+
This should return true for regular C libraries, but false for Python
337+
C extension modules.
338+
339+
Python extensions: .so (linux, mac), .pyd (windows)
340+
341+
C libraries: lib*.so (linux), lib*.so.* (linux), lib*.dylib (mac), .dll (windows)
341342
"""
342-
if not filename.startswith("lib"):
343-
return False
344-
if filename.endswith((".so", ".dylib", ".lib")):
343+
if filename.endswith(".dll"):
345344
return True
346-
347-
# Versioned library, e.g. libfoo.so.1.2.3
348-
if ".so." in filename:
345+
if filename.startswith("lib") and (
346+
filename.endswith((".so", ".dylib")) or ".so." in filename
347+
):
349348
return True
350349
return False
351350

tests/support/copy_file.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ def _copy_file_to_dir_impl(ctx):
88
inputs = [ctx.file.src],
99
outputs = [out_file],
1010
arguments = [ctx.file.src.path, out_file.path],
11+
# Perform a copy to better match how a file install from
12+
# a repo-phase (e.g. whl extraction) looks.
1113
command = 'cp -f "$1" "$2"',
1214
progress_message = "Copying %{input} to %{output}",
1315
)
1416
return [DefaultInfo(files = depset([out_file]))]
1517

1618
copy_file_to_dir = rule(
1719
implementation = _copy_file_to_dir_impl,
20+
doc = """
21+
This allows copying a file whose name is platform-dependent to a directory.
22+
23+
While bazel_skylib has a copy_file rule, you must statically specify the
24+
output file name.
25+
""",
1826
attrs = {
1927
"out_dir": attr.string(mandatory = True),
2028
"src": attr.label(

tests/venv_site_packages_libs/ext_with_libs/increment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
int increment(int);
55

6-
#endif // TESTS_VVENV_SITE_PACKAGES_LIBS_EXT_WITH_LIBS_INCREMENT_H_
6+
#endif // TESTS_VENV_SITE_PACKAGES_LIBS_EXT_WITH_LIBS_INCREMENT_H_

0 commit comments

Comments
 (0)