vimiv: init at 0.7.2

Packaging itself is pretty much straightforward, the tests however
revealed a few issues, which I have fixed with a small patch that has
been upstreamed at https://github.com/karlch/vimiv/pull/32.

The other sed-based patches in postPatch are mostly NixOS-specific.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2016-12-03 02:27:51 +01:00
parent 6343fef546
commit a76f5241c5
No known key found for this signature in database
GPG Key ID: 1DE8E48E57DB5436
3 changed files with 206 additions and 0 deletions

View File

@ -0,0 +1,74 @@
{ lib, python3Packages, fetchFromGitHub, imagemagick, librsvg, gtk3, jhead
, hicolor_icon_theme, defaultIconTheme
# Test requirements
, dbus, xvfb_run, xdotool
}:
python3Packages.buildPythonApplication rec {
name = "vimiv";
version = "0.7.2";
src = fetchFromGitHub {
owner = "karlch";
repo = "vimiv";
rev = "v${version}";
sha256 = "1g97ms84xk4ci4crq9wdc3744jnrqkq2qz9sg69lhm9sr5f68bw4";
};
testimages = fetchFromGitHub {
owner = "karlch";
repo = "vimiv";
rev = "6f4d1372b27f2065c56eafdb521d230d9bb8f4e2";
sha256 = "0a3aybzpms0381dz9japhm4c7j5klhmw91prcac6zaww6x34nmxb";
};
patches = [ ./fixes.patch ];
postPatch = ''
patchShebangs scripts/install_icons.sh
sed -i -e 's,/usr,,g' -e '/setup\.py/d' Makefile scripts/install_icons.sh
sed -i \
-e 's,/etc/vimiv/\(vimivrc\|keys\.conf\),'"$out"'&,g' \
man/* vimiv/parser.py
sed -i \
-e 's!"mogrify"!"${imagemagick}/bin/mogrify"!g' \
-e '/cmd *=/s!"jhead"!"${jhead}/bin/jhead"!g' \
vimiv/imageactions.py
'';
checkInputs = [ python3Packages.nose dbus.daemon xvfb_run xdotool ];
buildInputs = [ hicolor_icon_theme defaultIconTheme librsvg ];
propagatedBuildInputs = with python3Packages; [ pillow pygobject3 gtk3 ];
makeWrapperArgs = [
"--prefix GI_TYPELIB_PATH : \"$GI_TYPELIB_PATH\""
"--suffix XDG_DATA_DIRS : \"$XDG_ICON_DIRS:$out/share\""
"--set GDK_PIXBUF_MODULE_FILE \"$GDK_PIXBUF_MODULE_FILE\""
];
postCheck = ''
# Some tests assume that the directory only contains one vimiv directory
rm -rf vimiv.egg-info vimiv.desktop
# Re-use the wrapper args from the main program
makeWrapper "$SHELL" run-tests $makeWrapperArgs
cp -Rd --no-preserve=mode "$testimages/testimages" vimiv/testimages
HOME="$(mktemp -d)" PATH="$out/bin:$PATH" \
xvfb-run -s '-screen 0 800x600x24' dbus-run-session \
--config-file=${dbus.daemon}/share/dbus-1/session.conf \
./run-tests -c 'python tests/main_test.py && nosetests -vx'
'';
postInstall = "make DESTDIR=\"$out\" install";
meta = {
homepage = "https://github.com/karlch/vimiv";
description = "An image viewer with Vim-like keybindings";
license = lib.licenses.mit;
platforms = lib.platforms.linux;
};
}

View File

@ -0,0 +1,128 @@
Patch submitted upstream at https://github.com/karlch/vimiv/pull/32
diff --git a/tests/main_test.py b/tests/main_test.py
index a1870e7..2edc86d 100644
--- a/tests/main_test.py
+++ b/tests/main_test.py
@@ -15,7 +15,7 @@ class MainTest(TestCase):
def test_main_until_quit(self):
"""Run through vimiv main once."""
- v_main.main(True)
+ v_main.main([], True)
if __name__ == '__main__':
diff --git a/vimiv/helpers.py b/vimiv/helpers.py
index 22f0115..bfaf016 100644
--- a/vimiv/helpers.py
+++ b/vimiv/helpers.py
@@ -3,7 +3,6 @@
"""Wrappers around standard library functions used in vimiv."""
import os
-from subprocess import Popen, PIPE
from gi import require_version
require_version('Gtk', '3.0')
from gi.repository import Gtk
@@ -20,17 +19,17 @@ scrolltypes["K"] = (Gtk.ScrollType.START, False)
scrolltypes["L"] = (Gtk.ScrollType.END, True)
# A list of all external commands
-external_commands = []
-try:
- p = Popen('echo $PATH | tr \':\' \'\n\' | xargs -n 1 ls -1',
- stdout=PIPE, stderr=PIPE, shell=True)
- out, err = p.communicate()
- out = out.decode('utf-8').split()
- for cmd in sorted(list(set(out))):
- external_commands.append("!" + cmd)
-except:
- external_commands = []
-external_commands = tuple(external_commands)
+pathenv = os.environ.get('PATH')
+if pathenv is not None:
+ executables = set()
+ for path in pathenv.split(':'):
+ try:
+ executables |= set(["!" + e for e in os.listdir(path)])
+ except OSError:
+ continue
+ external_commands = tuple(sorted(list(executables)))
+else:
+ external_commands = ()
def listdir_wrapper(path, show_hidden=False):
diff --git a/vimiv/imageactions.py b/vimiv/imageactions.py
index d92eb73..b9bc986 100644
--- a/vimiv/imageactions.py
+++ b/vimiv/imageactions.py
@@ -157,8 +157,8 @@ class Thumbnails:
# Correct name
thumb_ext = ".thumbnail_%dx%d" % (self.thumbsize[0],
self.thumbsize[1])
- outfile_ext = infile.split(".")[0] + thumb_ext + ".png"
- outfile_base = os.path.basename(outfile_ext)
+ infile_base = os.path.basename(infile)
+ outfile_base = infile_base.split(".")[0] + thumb_ext + ".png"
outfile = os.path.join(self.directory, outfile_base)
# Only if they aren't cached already
if outfile_base not in self.thumbnails:
diff --git a/vimiv/main.py b/vimiv/main.py
index a0e38cf..39f7407 100644
--- a/vimiv/main.py
+++ b/vimiv/main.py
@@ -27,7 +27,7 @@ from vimiv.mark import Mark
from vimiv.information import Information
-def main(running_tests=False):
+def main(arguments, running_tests=False):
"""Starting point for vimiv.
Args:
@@ -36,7 +36,7 @@ def main(running_tests=False):
parser = get_args()
parse_dirs()
settings = parse_config()
- settings = parse_args(parser, settings)
+ settings = parse_args(parser, settings, arguments)
args = settings["GENERAL"]["paths"]
diff --git a/vimiv/parser.py b/vimiv/parser.py
index 874a538..9d5afce 100644
--- a/vimiv/parser.py
+++ b/vimiv/parser.py
@@ -56,7 +56,7 @@ def get_args():
return parser
-def parse_args(parser, settings, arguments=None):
+def parse_args(parser, settings, arguments):
"""Parse the arguments and return the modified settings.
Args:
@@ -66,10 +66,7 @@ def parse_args(parser, settings, arguments=None):
Return: Modified settings after parsing the arguments.
"""
- if arguments:
- args = parser.parse_args(arguments)
- else:
- args = parser.parse_args()
+ args = parser.parse_args(arguments)
if args.show_version:
information = Information()
print(information.get_version())
diff --git a/vimiv/vimiv b/vimiv/vimiv
index 5497e08..57f34f1 100755
--- a/vimiv/vimiv
+++ b/vimiv/vimiv
@@ -5,4 +5,4 @@ import sys
import vimiv
if __name__ == '__main__':
- sys.exit(vimiv.main.main())
+ sys.exit(vimiv.main.main(sys.argv))

View File

@ -14992,6 +14992,10 @@ in
inherit (darwin.apple_sdk.frameworks) Carbon Cocoa;
};
vimiv = callPackage ../applications/graphics/vimiv {
inherit (gnome3) defaultIconTheme;
};
macvim = callPackage ../applications/editors/vim/macvim.nix { stdenv = clangStdenv; ruby = ruby_2_2; };
vimHugeX = vim_configurable;