1{ buildPythonPackage, python, tornado, pycrypto, pycurl, pytz
2, pillow, derpconf, python_magic, libthumbor, webcolors
3, piexif, futures, statsd, thumborPexif, fetchFromGitHub, isPy3k, lib
4, mock, raven, nose, yanc, remotecv, pyssim, cairosvg, preggy, opencv3
5, pkgs, coreutils, substituteAll
6}:
7
8buildPythonPackage rec {
9 pname = "thumbor";
10 version = "6.7.0";
11
12 disabled = isPy3k; # see https://github.com/thumbor/thumbor/issues/1004
13
14 # Tests aren't included in PyPI tarball so use GitHub instead
15 src = fetchFromGitHub {
16 owner = pname;
17 repo = pname;
18 rev = version;
19 sha256 = "1qv02jz7ivn38dsywp7nxrlflly86x9pm2pk3yqi8m8myhc7lipg";
20 };
21
22 patches = [
23 (substituteAll {
24 src = ./0001-Don-t-use-which-implementation-to-find-required-exec.patch;
25 gifsicle = "${pkgs.gifsicle}/bin/gifsicle";
26 exiftool = "${pkgs.exiftool}/bin/exiftool";
27 jpegtran = "${pkgs.libjpeg}/bin/jpegtran";
28 ffmpeg = "${pkgs.ffmpeg_3}/bin/ffmpeg";
29 })
30 ];
31
32 postPatch = ''
33 substituteInPlace "setup.py" \
34 --replace '"argparse",' "" ${lib.optionalString isPy3k ''--replace '"futures",' ""''}
35 sed -i setup.py \
36 -e 's/piexif[^"]*/piexif/;s/Pillow[^"]*/Pillow/'
37 substituteInPlace "tests/test_utils.py" \
38 --replace "/bin/ls" "${coreutils}/bin/ls"
39 substituteInPlace "tests/detectors/test_face_detector.py" \
40 --replace "./thumbor" "$out/lib/${python.libPrefix}/site-packages/thumbor"
41 substituteInPlace "tests/detectors/test_glasses_detector.py" \
42 --replace "./thumbor" "$out/lib/${python.libPrefix}/site-packages/thumbor"
43 '';
44
45 checkInputs = [
46 nose
47 pyssim
48 preggy
49 mock
50 yanc
51 remotecv
52 raven
53 pkgs.redis
54 pkgs.glibcLocales
55 pkgs.gifsicle
56 ];
57
58 propagatedBuildInputs = [
59 tornado
60 pycrypto
61 pycurl
62 pytz
63 pillow
64 derpconf
65 python_magic
66 libthumbor
67 opencv3
68 webcolors
69 piexif
70 statsd
71 cairosvg
72 ] ++ lib.optionals (!isPy3k) [ futures thumborPexif ];
73
74 # Remove the source tree before running nosetests because otherwise nosetests
75 # uses that instead of the installed package. Is there some other way to
76 # achieve this?
77 checkPhase = ''
78 redis-server --port 6668 --requirepass hey_you &
79 rm -r thumbor
80 export LC_ALL="en_US.UTF-8"
81 nosetests -v --with-yanc -s tests/ -e test_redeye_applied
82 '';
83
84 meta = with lib; {
85 description = "A smart imaging service";
86 homepage = "https://github.com/thumbor/thumbor/wiki";
87 license = licenses.mit;
88 maintainers = with maintainers; [ ];
89 };
90}