summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-11-01 09:48:34 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-11-01 10:41:44 +0100
commitc3f77d40eb666cf890bd8a940ece7bb3a330d572 (patch)
treec8c9672c94fd48a6904a8bb2f369fd4a15f5f7b9
parentc8092499ec566548702413ae23a8386a62f4c73d (diff)
downloadqutebrowser-c3f77d40eb666cf890bd8a940ece7bb3a330d572.tar.gz
qutebrowser-c3f77d40eb666cf890bd8a940ece7bb3a330d572.zip
Bring back PyInstaller resource handling
Seems to be still needed, at least on macOS. Otherwise, we get a NotADirectoryError trying to load resources from a weird path under the qutebrowser executable. See #6792
-rw-r--r--qutebrowser/utils/resources.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/qutebrowser/utils/resources.py b/qutebrowser/utils/resources.py
index cd6284f7f..f561d6747 100644
--- a/qutebrowser/utils/resources.py
+++ b/qutebrowser/utils/resources.py
@@ -40,6 +40,12 @@ def _path(filename: str) -> pathlib.Path:
"""Get a pathlib.Path object for a resource."""
assert not posixpath.isabs(filename), filename
assert os.path.pardir not in filename.split(posixpath.sep), filename
+
+ if hasattr(sys, 'frozen'):
+ # For PyInstaller, where we can't store resource files in a qutebrowser/ folder
+ # because the executable is already named "qutebrowser" (at least on macOS).
+ return pathlib.Path(sys.executable).parent / filename
+
return importlib_resources.files(qutebrowser) / filename
@contextlib.contextmanager