Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions python/private/get_local_runtime_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@
# of settings.
# https://stackoverflow.com/questions/47423246/get-pythons-lib-path
# For now, it seems LIBDIR has what is needed, so just use that.
# See also: MULTIARCH
"LIBDIR",
# On Debian, with multiarch enabled, prior to Python 3.10, `LIBDIR` didn't
# tell the location of the libs, just the base directory. The `MULTIARCH`
# sysconfig variable tells the subdirectory within it with the libs.
# See:
# https://wiki.debian.org/Python/MultiArch
# https://git.launchpad.net/ubuntu/+source/python3.12/tree/debian/changelog#n842
"MULTIARCH",
# The versioned libpythonX.Y.so.N file. Usually?
# It might be a static archive (.a) file instead.
"INSTSONAME",
Expand Down
6 changes: 6 additions & 0 deletions python/private/local_runtime_repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def _local_runtime_repo_impl(rctx):
# In some cases, the same value is returned for multiple keys. Not clear why.
shared_lib_names = {v: None for v in shared_lib_names}.keys()
shared_lib_dir = info["LIBDIR"]
multiarch = info["MULTIARCH"]

# The specific files are symlinked instead of the whole directory
# because it can point to a directory that has more than just
Expand All @@ -135,6 +136,11 @@ def _local_runtime_repo_impl(rctx):
for name in shared_lib_names:
origin = rctx.path("{}/{}".format(shared_lib_dir, name))

# If the origin doesn't exist, try the multiarch location, in case
# it's an older Python / Debian release.
if not origin.exists and multiarch:
origin = rctx.path("{}/{}/{}".format(shared_lib_dir, multiarch, name))

# The reported names don't always exist; it depends on the particulars
# of the runtime installation.
if origin.exists:
Expand Down