summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-11-25 12:13:56 +0100
committerFlorian Bruhin <me@the-compiler.org>2020-11-25 14:07:45 +0100
commitab056a8fe90452a8cf8ba7864b0c10cf53a4f6fc (patch)
treee7c4a63b305af08f666b70754ff8427ca3228d0c
parent3701aed8fbe8f65ce34a785e4161b85db737a1ab (diff)
downloadqutebrowser-ab056a8fe90452a8cf8ba7864b0c10cf53a4f6fc.tar.gz
qutebrowser-ab056a8fe90452a8cf8ba7864b0c10cf53a4f6fc.zip
scripts: Fix mkvenv.py with multilib libraries
-rw-r--r--scripts/mkvenv.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/scripts/mkvenv.py b/scripts/mkvenv.py
index 36d4033c7..084062509 100644
--- a/scripts/mkvenv.py
+++ b/scripts/mkvenv.py
@@ -25,6 +25,7 @@ import argparse
import pathlib
import sys
import os
+import re
import os.path
import shutil
import venv
@@ -239,16 +240,26 @@ def apply_xcb_util_workaround(
return
libs = _find_libs()
- if 'libxcb-util.so.1' in libs:
+ abi_type = 'libc6,x86-64' # the only one PyQt wheels are available for
+
+ if ('libxcb-util.so.1', abi_type) in libs:
print("Workaround not needed: libxcb-util.so.1 found.")
return
try:
- libxcb_util_path = pathlib.Path(libs['libxcb-util.so.0'])
+ libxcb_util_libs = libs['libxcb-util.so.0', abi_type]
except KeyError:
utils.print_col('Workaround failed: libxcb-util.so.0 not found.', 'red')
return
+ if len(libxcb_util_libs) > 1:
+ utils.print_col(
+ f'Workaround failed: Multiple matching libxcb-util found: '
+ f'{libxcb_util_libs}', 'red')
+ return
+
+ libxcb_util_path = pathlib.Path(libxcb_util_libs[0])
+
code = [
'from PyQt5.QtCore import QLibraryInfo',
'print(QLibraryInfo.location(QLibraryInfo.LibrariesPath))',
@@ -266,7 +277,7 @@ def apply_xcb_util_workaround(
link_path.symlink_to(libxcb_util_path)
-def _find_libs() -> Dict[str, str]:
+def _find_libs() -> Dict[Tuple[str, str], List[str]]:
"""Find all system-wide .so libraries."""
all_libs: Dict[str, str] = {}
ldconfig_proc = subprocess.run(
@@ -275,15 +286,19 @@ def _find_libs() -> Dict[str, str]:
stdout=subprocess.PIPE,
encoding=sys.getfilesystemencoding(),
)
+ pattern = re.compile(r'(?P<name>\S+) \((?P<abi_type>[^)]+)\) => (?P<path>.*)')
for line in ldconfig_proc.stdout.splitlines():
- if ' => ' not in line:
+ match = pattern.fullmatch(line.strip())
+ if match is None:
+ if 'libs found in cache' not in line:
+ utils.print_col(f'Failed to match ldconfig output: {line}', 'yellow')
continue
- line = line.strip()
- name, path = line.split(' => ')
- name = name.split(' (')[0]
- if name in all_libs:
- raise ValueError(f'Found duplicate {name} ({all_libs[name]}; {path})')
- all_libs[name] = path
+
+ key = match.group('name'), match.group('abi_type')
+ path = match.group('path')
+
+ libs = all_libs.setdefault(key, [])
+ libs.append(path)
return all_libs