summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2014-12-28 14:50:25 +0100
committerFlorian Bruhin <git@the-compiler.org>2014-12-28 14:50:25 +0100
commitf1435ce51f2fa2bfac9dcff55d94992e4b5e7e00 (patch)
tree32b77ef285447f68784f18685dd38eea6a4d6657
parent2a4e884e1b89b731301cf3bc46c7abe4115c3b44 (diff)
downloadqutebrowser-f1435ce51f2fa2bfac9dcff55d94992e4b5e7e00.tar.gz
qutebrowser-f1435ce51f2fa2bfac9dcff55d94992e4b5e7e00.zip
Use a dirty hack to copy icon files into package.
See #325.
-rw-r--r--.gitignore1
-rw-r--r--MANIFEST.in1
-rw-r--r--qutebrowser/app.py2
-rw-r--r--qutebrowser/utils/utils.py10
-rwxr-xr-xsetup.py20
5 files changed, 17 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index 3cb08b141..b1147c670 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ __pycache__
/setuptools-*.egg
/setuptools-*.zip
/qutebrowser/git-commit-id
+/qutebrowser/icons
/doc/*.html
/README.html
/qutebrowser/html/doc/
diff --git a/MANIFEST.in b/MANIFEST.in
index 7f3eeb898..919ef3d55 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,5 +1,6 @@
recursive-include qutebrowser/html *.html
recursive-include qutebrowser/test *.py
+recursive-include qutebrowser/icons *
recursive-include icons *
include qutebrowser/test/testfile
include qutebrowser/git-commit-id
diff --git a/qutebrowser/app.py b/qutebrowser/app.py
index 5989cc6a8..c6d2d5ea1 100644
--- a/qutebrowser/app.py
+++ b/qutebrowser/app.py
@@ -203,7 +203,7 @@ class Application(QApplication):
icon = QIcon()
for size in (16, 24, 32, 48, 64, 96, 128, 256, 512):
filename = 'icons/qutebrowser-{}x{}.png'.format(size, size)
- data = utils.read_file(filename, binary=True, use_requirement=True)
+ data = utils.read_file(filename, binary=True)
pixmap = QPixmap()
ok = pixmap.loadFromData(data, 'PNG')
if not ok:
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py
index b2aea8112..4b40f997d 100644
--- a/qutebrowser/utils/utils.py
+++ b/qutebrowser/utils/utils.py
@@ -64,15 +64,13 @@ def compact_text(text, elidelength=None):
return out
-def read_file(filename, binary=False, use_requirement=False):
+def read_file(filename, binary=False):
"""Get the contents of a file contained with qutebrowser.
Args:
filename: The filename to open as string.
binary: Whether to return a binary string.
If False, the data is UTF-8-decoded.
- use_requirement: Use a pkg_resources.Requirement object to get
- non-package data.
Return:
The file contents as string.
@@ -87,11 +85,7 @@ def read_file(filename, binary=False, use_requirement=False):
with open(fn, 'r', encoding='utf-8') as f:
return f.read()
else:
- if use_requirement:
- target = pkg_resources.Requirement('qutebrowser', '', '')
- else:
- target = qutebrowser.__name__
- data = pkg_resources.resource_string(target, filename)
+ data = pkg_resources.resource_string(qutebrowser.__name__, filename)
if not binary:
data = data.decode('UTF-8')
return data
diff --git a/setup.py b/setup.py
index fcbb19aae..f525b6775 100755
--- a/setup.py
+++ b/setup.py
@@ -24,16 +24,21 @@
import os
import os.path
import glob
+import shutil
from scripts import setupcommon as common
import setuptools
-try:
- BASEDIR = os.path.dirname(os.path.realpath(__file__))
-except NameError:
- BASEDIR = None
+BASEDIR = os.path.dirname(os.path.realpath(__file__))
+
+
+icon_path = os.path.join('qutebrowser', 'icons')
+shutil.rmtree(icon_path)
+os.mkdir(icon_path)
+for fn in glob.glob('icons/*.png'):
+ shutil.copy(fn, icon_path)
try:
@@ -50,7 +55,6 @@ try:
**common.setupdata
)
finally:
- if BASEDIR is not None:
- path = os.path.join(BASEDIR, 'qutebrowser', 'git-commit-id')
- if os.path.exists(path):
- os.remove(path)
+ path = os.path.join(BASEDIR, 'qutebrowser', 'git-commit-id')
+ if os.path.exists(path):
+ os.remove(path)