Skip to content

Commit ed49e9d

Browse files
committed
make multiarch origin a fallback
1 parent e14a64f commit ed49e9d

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

python/private/get_local_runtime_info.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@
3535
# of settings.
3636
# https://stackoverflow.com/questions/47423246/get-pythons-lib-path
3737
# For now, it seems LIBDIR has what is needed, so just use that.
38+
# See also: MULTIARCH
3839
"LIBDIR",
40+
# On Debian, with multiarch enabled, prior to Python 3.10, `LIBDIR` didn't
41+
# tell the location of the libs, just the base directory. The `MULTIARCH`
42+
# sysconfig variable tells the subdirectory within it with the libs.
43+
# See:
44+
# https://wiki.debian.org/Python/MultiArch
45+
# https://git.launchpad.net/ubuntu/+source/python3.12/tree/debian/changelog#n842
46+
"MULTIARCH",
3947
# The versioned libpythonX.Y.so.N file. Usually?
4048
# It might be a static archive (.a) file instead.
4149
"INSTSONAME",
@@ -45,11 +53,6 @@
4553
# The platform-specific filename suffix for library files.
4654
# Includes the dot, e.g. `.so`
4755
"SHLIB_SUFFIX",
48-
# Debian has a "multiarch" layout that has libs for different archs
49-
# in slightly other locations. The MULTIARCH sysconfig varible tells
50-
# which directory under `LIBDIR` these exist in, if any.
51-
# See https://wiki.debian.org/Python/MultiArch
52-
"MULTIARCH",
5356
]
5457
data.update(zip(config_vars, sysconfig.get_config_vars(*config_vars)))
5558
print(json.dumps(data))

python/private/local_runtime_repo.bzl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,16 @@ def _local_runtime_repo_impl(rctx):
136136
for name in shared_lib_names:
137137
origin = rctx.path("{}/{}".format(shared_lib_dir, name))
138138

139+
# If the origin doesn't exist, try the multiarch location
140+
if not origin.exists and multiarch:
141+
origin = rctx.path("{}/{}/{}".format(shared_lib_dir, multiarch, name))
142+
139143
# The reported names don't always exist; it depends on the particulars
140144
# of the runtime installation.
141145
if origin.exists:
142146
repo_utils.watch(rctx, origin)
143147
rctx.symlink(origin, "lib/" + name)
144148

145-
origin_multiarch = rctx.path("{}/{}/{}".format(shared_lib_dir, multiarch, name))
146-
if origin_multiarch.exists:
147-
repo_utils.watch(rctx, origin)
148-
rctx.symlink(origin, "lib/{}/{}".format(multiarch, name))
149-
150149
rctx.file("WORKSPACE", "")
151150
rctx.file("MODULE.bazel", "")
152151
rctx.file("REPO.bazel", "")

0 commit comments

Comments
 (0)