diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-11-01 09:48:34 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-11-01 09:48:34 +0100 |
commit | 08162cbfeb9c56849611911a2d34e0f22bf72629 (patch) | |
tree | ffab0668130c2d39ea6f173946f10fe127db2903 | |
parent | 2df2cb280e599b2d313b943afd903d59984c2a9f (diff) | |
download | qutebrowser-08162cbfeb9c56849611911a2d34e0f22bf72629.tar.gz qutebrowser-08162cbfeb9c56849611911a2d34e0f22bf72629.zip |
Bring back PyInstaller resource handling
Seems to be still needed, at least on macOS
-rw-r--r-- | qutebrowser/utils/resources.py | 6 |
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 |