Revert "Remove pkg_resources special casing for PyInstaller"
This reverts commit 6bb2b082c9.
I guess storing package data in qutebrowser/ would be the proper way,
but this doesn't actually work on macOS - there, the executable name is
already "qutebrowser"...
This commit is contained in:
parent
6bb2b082c9
commit
eeb26a6aa8
|
|
@ -13,17 +13,16 @@ block_cipher = None
|
|||
|
||||
def get_data_files():
|
||||
data_files = [
|
||||
('../qutebrowser/html', 'qutebrowser/html'),
|
||||
('../qutebrowser/img', 'qutebrowser/img'),
|
||||
('../qutebrowser/javascript', 'qutebrowser/javascript'),
|
||||
('../qutebrowser/html/doc', 'qutebrowser/html/doc'),
|
||||
('../qutebrowser/git-commit-id', 'qutebrowser/'),
|
||||
('../qutebrowser/config/configdata.yml', 'qutebrowser/config'),
|
||||
('../qutebrowser/html', 'html'),
|
||||
('../qutebrowser/img', 'img'),
|
||||
('../qutebrowser/javascript', 'javascript'),
|
||||
('../qutebrowser/html/doc', 'html/doc'),
|
||||
('../qutebrowser/git-commit-id', '.'),
|
||||
('../qutebrowser/config/configdata.yml', 'config'),
|
||||
]
|
||||
|
||||
if os.path.exists(os.path.join('qutebrowser', '3rdparty', 'pdfjs')):
|
||||
data_files.append(
|
||||
('../qutebrowser/3rdparty/pdfjs', 'qutebrowser/3rdparty/pdfjs'))
|
||||
data_files.append(('../qutebrowser/3rdparty/pdfjs', '3rdparty/pdfjs'))
|
||||
else:
|
||||
print("Warning: excluding pdfjs as it's not present!")
|
||||
|
||||
|
|
|
|||
|
|
@ -208,12 +208,24 @@ def read_file(filename: str, binary: bool = False) -> Any:
|
|||
if not binary and filename in _resource_cache:
|
||||
return _resource_cache[filename]
|
||||
|
||||
p = importlib_resources.files(qutebrowser) / filename
|
||||
if hasattr(sys, 'frozen'):
|
||||
# PyInstaller doesn't support pkg_resources :(
|
||||
# https://github.com/pyinstaller/pyinstaller/wiki/FAQ#misc
|
||||
fn = os.path.join(os.path.dirname(sys.executable), filename)
|
||||
if binary:
|
||||
f: IO
|
||||
with open(fn, 'rb') as f:
|
||||
return f.read()
|
||||
else:
|
||||
with open(fn, 'r', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
else:
|
||||
p = importlib_resources.files(qutebrowser) / filename
|
||||
|
||||
if binary:
|
||||
return p.read_bytes()
|
||||
if binary:
|
||||
return p.read_bytes()
|
||||
|
||||
return p.read_text()
|
||||
return p.read_text()
|
||||
|
||||
|
||||
def resource_filename(filename: str) -> str:
|
||||
|
|
|
|||
Loading…
Reference in New Issue