diff --git a/pkgs/development/python-modules/cairosvg/1_x.nix b/pkgs/development/python-modules/cairosvg/1_x.nix new file mode 100644 index 000000000000..b6d40a5fdb70 --- /dev/null +++ b/pkgs/development/python-modules/cairosvg/1_x.nix @@ -0,0 +1,37 @@ +{ stdenv, buildPythonPackage, fetchFromGitHub, cairocffi, nose, fontconfig +, cssselect2, defusedxml, pillow, tinycss2 }: + +# CairoSVG 2.x dropped support for Python 2 so offer CairoSVG 1.x as an +# alternative +buildPythonPackage rec { + pname = "CairoSVG"; + version = "1.0.22"; + + # PyPI doesn't include tests so use GitHub + src = fetchFromGitHub { + owner = "Kozea"; + repo = pname; + rev = version; + sha256 = "15z0cag5s79ghhrlgs5xc9ayvzzdr3v8151vf6k819f1drsfjfxl"; + }; + + propagatedBuildInputs = [ cairocffi ]; + + checkInputs = [ nose fontconfig cssselect2 defusedxml pillow tinycss2 ]; + + # Almost all tests just fail. Not sure how to fix them. + doCheck = false; + + # checkInputs = [ nose fontconfig cssselect2 defusedxml pillow tinycss2 ]; + + # checkPhase = '' + # FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf nosetests . + # ''; + + meta = with stdenv.lib; { + homepage = https://cairosvg.org; + license = licenses.lgpl3; + description = "SVG converter based on Cairo"; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/nose-focus/default.nix b/pkgs/development/python-modules/nose-focus/default.nix new file mode 100644 index 000000000000..ef86a35b3041 --- /dev/null +++ b/pkgs/development/python-modules/nose-focus/default.nix @@ -0,0 +1,35 @@ +{ stdenv, buildPythonPackage, fetchFromGitHub, six, nose, nose-of-yeti +, nose-pattern-exclude, which }: + +buildPythonPackage rec { + pname = "nose-focus"; + version = "0.1.3"; + + propagatedBuildInputs = [ six ]; + + checkInputs = [ nose nose-of-yeti nose-pattern-exclude which ]; + + # PyPI doesn't contain tests so let's use GitHub. See: + # https://github.com/delfick/nose-focus/issues/4 + # + # However, the versions aren't tagged on GitHub so need to use a manually + # checked revision. See: https://github.com/delfick/nose-focus/issues/5 + src = fetchFromGitHub { + owner = "delfick"; + repo = pname; + rev = "4dac785ba07ed6e1df61b0fe2854685eef3bd115"; + sha256 = "0gpd4j4433dc5ifh31w08c3bx862md0qm1ix6aam1rz4ayxpq51f"; + }; + + checkPhase = '' + patchShebangs test.sh + ./test.sh + ''; + + meta = with stdenv.lib; { + description = "Decorator and plugin to make nose focus on specific tests"; + homepage = https://nose-focus.readthedocs.io/en/latest/; + license = licenses.wtfpl; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/nose-of-yeti/default.nix b/pkgs/development/python-modules/nose-of-yeti/default.nix new file mode 100644 index 000000000000..7a783da31177 --- /dev/null +++ b/pkgs/development/python-modules/nose-of-yeti/default.nix @@ -0,0 +1,30 @@ +{ stdenv, buildPythonPackage, fetchFromGitHub, six, nose, fudge, should-dsl }: + +buildPythonPackage rec { + pname = "nose-of-yeti"; + version = "1.8"; + + propagatedBuildInputs = [ six ]; + + checkInputs = [ nose fudge should-dsl ]; + + # PyPI doesn't contain tests so let's use GitHub. + src = fetchFromGitHub { + owner = "delfick"; + repo = pname; + rev = "v${version}"; + sha256 = "1pq9bf47k0csv41vdh2g6n336p3pd11q91hj5ypk0ls3nj756gbx"; + }; + + checkPhase = '' + patchShebangs test.sh + ./test.sh + ''; + + meta = with stdenv.lib; { + description = "Nose plugin providing BDD dsl for python"; + homepage = https://github.com/delfick/nose-of-yeti; + license = licenses.mit; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/nose-pattern-exclude/default.nix b/pkgs/development/python-modules/nose-pattern-exclude/default.nix new file mode 100644 index 000000000000..24d74b938afb --- /dev/null +++ b/pkgs/development/python-modules/nose-pattern-exclude/default.nix @@ -0,0 +1,23 @@ +{ stdenv, buildPythonPackage, fetchPypi, nose }: + +buildPythonPackage rec { + pname = "nose-pattern-exclude"; + version = "0.1.3"; + + propagatedBuildInputs = [ nose ]; + + src = fetchPypi { + inherit pname version; + sha256 = "0apzxx8lavsdlxlpaxqw1snx5p7q8v5dfbip6v32f9pj2vyain1i"; + }; + + # There are no tests + doCheck = false; + + meta = with stdenv.lib; { + description = "Exclude specific files and directories from nosetests runs"; + homepage = https://github.com/jakubroztocil/nose-pattern-exclude; + license = licenses.bsd3; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/piexif/default.nix b/pkgs/development/python-modules/piexif/default.nix index b5460e8b6080..0de96a3f585e 100644 --- a/pkgs/development/python-modules/piexif/default.nix +++ b/pkgs/development/python-modules/piexif/default.nix @@ -2,22 +2,15 @@ buildPythonPackage rec { pname = "piexif"; - version = "1.0.13"; + version = "1.1.2"; - # pillow needed for unit tests - buildInputs = [ pillow ]; - - postPatch = '' - # incompatibility with pillow => 4.2.0 - # has been resolved in https://github.com/hMatoba/Piexif/commit/c3a8272f5e6418f223b25f6486d8ddda201bbdf1 - # remove this in the next version - sed -i -e 's/RGBA/RGB/' tests/s_test.py - ''; + # Pillow needed for unit tests + checkInputs = [ pillow ]; src = fetchPypi { inherit pname version; extension = "zip"; - sha256 = "1d3dde03bd6298393645bc11d585b67a6ea98fd7e9e1aded6d5d6ec3e4cfbdda"; + sha256 = "0dj6wiw4mk65zn7p0qpghra39mf88m3ph2xn7ff9jvasgczrgkb0"; }; meta = with stdenv.lib; { diff --git a/pkgs/development/python-modules/preggy/default.nix b/pkgs/development/python-modules/preggy/default.nix new file mode 100644 index 000000000000..b88366de88fa --- /dev/null +++ b/pkgs/development/python-modules/preggy/default.nix @@ -0,0 +1,25 @@ +{ stdenv, buildPythonPackage, fetchPypi, six, unidecode, nose, yanc }: + +buildPythonPackage rec { + pname = "preggy"; + version = "1.4.2"; + + propagatedBuildInputs = [ six unidecode ]; + checkInputs = [ nose yanc ]; + + src = fetchPypi { + inherit pname version; + sha256 = "0g4ifjh01dkmdzs4621ahk8hpkngid1xxhl51jvzy4h4li4590hw"; + }; + + checkPhase = '' + nosetests . + ''; + + meta = with stdenv.lib; { + description = "Assertion library for Python"; + homepage = http://heynemann.github.io/preggy/; + license = licenses.mit; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/pyres/default.nix b/pkgs/development/python-modules/pyres/default.nix new file mode 100644 index 000000000000..2ea6043c4279 --- /dev/null +++ b/pkgs/development/python-modules/pyres/default.nix @@ -0,0 +1,45 @@ +{ stdenv, fetchPypi, buildPythonPackage, fetchFromGitHub, simplejson, redis, setproctitle, nose, pkgs }: + +let + + # the requirements of `pyres` support Redis 3.x (due to a missing upper-bound), + # but it doesn't support Redis 3.x. + redis' = redis.overridePythonAttrs (old: rec { + pname = "redis"; + version = "2.10.6"; + src = fetchPypi { + inherit pname version; + sha256 = "03vcgklykny0g0wpvqmy8p6azi2s078317wgb2xjv5m2rs9sjb52"; + }; + }); + +in + +buildPythonPackage rec { + pname = "pyres"; + version = "1.5"; + + # ps is used in Worker.worker_pids method + propagatedBuildInputs = [ simplejson setproctitle redis' pkgs.ps ]; + checkInputs = [ nose pkgs.redis ]; + + # PyPI tarball doesn't contain tests so let's use GitHub + src = fetchFromGitHub { + owner = "binarydud"; + repo = pname; + rev = version; + sha256 = "1rkpv7gbjxl9h9g7kncmsrgmi77l7pgfq8d7dbnsr3ia2jmjqb8y"; + }; + + checkPhase = '' + redis-server & + nosetests . + ''; + + meta = with stdenv.lib; { + description = "Python resque clone"; + homepage = https://github.com/binarydud/pyres; + license = licenses.mit; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/pyssim/default.nix b/pkgs/development/python-modules/pyssim/default.nix new file mode 100644 index 000000000000..38dddda9b2e5 --- /dev/null +++ b/pkgs/development/python-modules/pyssim/default.nix @@ -0,0 +1,32 @@ +{ stdenv, buildPythonPackage, fetchFromGitHub, numpy, scipy, pillow }: + +buildPythonPackage rec { + pname = "pyssim"; + version = "0.4"; + + propagatedBuildInputs = [ numpy scipy pillow ]; + + # PyPI tarball doesn't contain test images so let's use GitHub + src = fetchFromGitHub { + owner = "jterrace"; + repo = pname; + rev = "v${version}"; + sha256 = "0rnj3xdhma1fc0fg0jjsdy74ar0hgr3w8kygbnijqjdms7m3asqm"; + }; + + # Tests are copied from .travis.yml + checkPhase = '' + $out/bin/pyssim test-images/test1-1.png test-images/test1-1.png | grep 1 + $out/bin/pyssim test-images/test1-1.png test-images/test1-2.png | grep 0.998 + $out/bin/pyssim test-images/test1-1.png "test-images/*" | grep -E " 1| 0.998| 0.672| 0.648" | wc -l | grep 4 + $out/bin/pyssim --cw --width 128 --height 128 test-images/test1-1.png test-images/test1-1.png | grep 1 + $out/bin/pyssim --cw --width 128 --height 128 test-images/test3-orig.jpg test-images/test3-rot.jpg | grep 0.938 + ''; + + meta = with stdenv.lib; { + description = "Module for computing Structured Similarity Image Metric (SSIM) in Python"; + homepage = https://github.com/jterrace/pyssim; + license = licenses.mit; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/remotecv/default.nix b/pkgs/development/python-modules/remotecv/default.nix new file mode 100644 index 000000000000..2102cf064250 --- /dev/null +++ b/pkgs/development/python-modules/remotecv/default.nix @@ -0,0 +1,38 @@ +{ stdenv, buildPythonPackage, fetchFromGitHub, pillow, argparse, pyres, nose +, preggy, numpy, yanc, nose-focus, mock, opencv }: + +buildPythonPackage rec { + pname = "remotecv"; + version = "2.2.2"; + + propagatedBuildInputs = [ pillow argparse pyres ]; + + checkInputs = [ nose preggy numpy yanc nose-focus mock opencv ]; + + # PyPI tarball doesn't contain tests so let's use GitHub + src = fetchFromGitHub { + owner = "thumbor"; + repo = pname; + rev = version; + sha256 = "0slalp1x626ajy2cbdfifhxf0ffzckqdz6siqsqr6s03hrl877hy"; + }; + + # Remove unnecessary argparse dependency and some seemingly unnecessary + # version upper bounds because nixpkgs contains (or could contain) newer + # versions. + # See: https://github.com/thumbor/remotecv/issues/15 + patches = [ + ./install_requires.patch + ]; + + checkPhase = '' + nosetests --with-yanc -s tests/ + ''; + + meta = with stdenv.lib; { + description = "OpenCV worker for facial and feature recognition"; + homepage = https://github.com/thumbor/remotecv/wiki; + license = licenses.mit; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/remotecv/install_requires.patch b/pkgs/development/python-modules/remotecv/install_requires.patch new file mode 100644 index 000000000000..37203128486e --- /dev/null +++ b/pkgs/development/python-modules/remotecv/install_requires.patch @@ -0,0 +1,16 @@ +diff --git a/setup.py b/setup.py +index 70f765c..8003cda 100644 +--- a/setup.py ++++ b/setup.py +@@ -53,9 +53,8 @@ remotecv is an OpenCV worker for facial and feature recognition + }, + + install_requires=[ +- "argparse>=1.2.1,<1.3.0", +- "pyres>=1.5,<1.6", +- "Pillow>=4.3.0,<5.2.0", ++ "pyres>=1.5", ++ "Pillow>=4.3.0", + ], + + entry_points={ diff --git a/pkgs/development/python-modules/should-dsl/default.nix b/pkgs/development/python-modules/should-dsl/default.nix new file mode 100644 index 000000000000..987d7e60cea6 --- /dev/null +++ b/pkgs/development/python-modules/should-dsl/default.nix @@ -0,0 +1,22 @@ +{ stdenv, buildPythonPackage, fetchPypi }: + +buildPythonPackage rec { + pname = "should-dsl"; + version = "2.1.2"; + + src = fetchPypi { + inherit version; + pname = "should_dsl"; + sha256 = "0ai30dxgygwzaj9sgdzyfr9p5b7gwc9piq59nzr4xy5x1zcm7xrn"; + }; + + # There are no tests + doCheck = false; + + meta = with stdenv.lib; { + description = "Should assertions in Python as clear and readable as possible"; + homepage = http://www.should-dsl.info/; + license = licenses.mit; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/development/python-modules/thumbor/default.nix b/pkgs/development/python-modules/thumbor/default.nix index ec33a5020d47..27e90514b729 100644 --- a/pkgs/development/python-modules/thumbor/default.nix +++ b/pkgs/development/python-modules/thumbor/default.nix @@ -1,6 +1,8 @@ -{ buildPythonPackage, tornado, pycrypto, pycurl, pytz -, pillow, derpconf, python_magic, pexif, libthumbor, opencv, webcolors -, piexif, futures, statsd, thumborPexif, fetchPypi, isPy3k, lib +{ buildPythonPackage, python, tornado, pycrypto, pycurl, pytz +, pillow, derpconf, python_magic, libthumbor, webcolors +, piexif, futures, statsd, thumborPexif, fetchFromGitHub, isPy3k, lib +, mock, raven, nose, yanc, remotecv, pyssim, cairosvg1, preggy, opencv3 +, pkgs, coreutils }: buildPythonPackage rec { @@ -9,16 +11,40 @@ buildPythonPackage rec { disabled = isPy3k; # see https://github.com/thumbor/thumbor/issues/1004 - src = fetchPypi { - inherit pname version; - sha256 = "1icfnzwzi5lvnh576n7v3r819jaw15ph9ja2w3fwg5z9qs40xvl8"; + # Tests aren't included in PyPI tarball so use GitHub instead + src = fetchFromGitHub { + owner = pname; + repo = pname; + rev = version; + sha256 = "1ys5ymwbvgh2ir85g9nyrzzf8vgi16j6pzzi53b0rgjx0kwlmnxg"; }; postPatch = '' substituteInPlace "setup.py" \ --replace '"argparse",' "" ${lib.optionalString isPy3k ''--replace '"futures",' ""''} + substituteInPlace "setup.py" \ + --replace "piexif>=1.0.13,<1.1.0" "piexif>=1.0.13" + substituteInPlace "tests/test_utils.py" \ + --replace "/bin/ls" "${coreutils}/bin/ls" + substituteInPlace "tests/detectors/test_face_detector.py" \ + --replace "./thumbor" "$out/lib/${python.libPrefix}/site-packages/thumbor" + substituteInPlace "tests/detectors/test_glasses_detector.py" \ + --replace "./thumbor" "$out/lib/${python.libPrefix}/site-packages/thumbor" ''; + checkInputs = [ + nose + pyssim + preggy + mock + yanc + remotecv + cairosvg1 + raven + pkgs.redis + pkgs.glibcLocales + ]; + propagatedBuildInputs = [ tornado pycrypto @@ -27,18 +53,26 @@ buildPythonPackage rec { pillow derpconf python_magic - pexif libthumbor - opencv + opencv3 webcolors piexif statsd + pkgs.exiftool + pkgs.libjpeg + pkgs.ffmpeg + pkgs.gifsicle ] ++ lib.optionals (!isPy3k) [ futures thumborPexif ]; - # disabled due to too many impure tests and issues with native modules in - # the pure testing environment. See https://github.com/NixOS/nixpkgs/pull/37147 - # for further reference. - doCheck = false; + # Remove the source tree before running nosetests because otherwise nosetests + # uses that instead of the installed package. Is there some other way to + # achieve this? + checkPhase = '' + redis-server --port 6668 --requirepass hey_you & + rm -r thumbor + export LC_ALL="en_US.UTF-8" + nosetests -v --with-yanc -s tests/ + ''; meta = with lib; { description = "A smart imaging service"; diff --git a/pkgs/development/python-modules/yanc/default.nix b/pkgs/development/python-modules/yanc/default.nix new file mode 100644 index 000000000000..690b110fc93a --- /dev/null +++ b/pkgs/development/python-modules/yanc/default.nix @@ -0,0 +1,27 @@ +{ stdenv, buildPythonPackage, pythonOlder, fetchPypi, nose }: + +buildPythonPackage rec { + pname = "yanc"; + version = "0.3.3"; + + # Tests fail on Python>=3.5. See: https://github.com/0compute/yanc/issues/10 + disabled = !(pythonOlder "3.5"); + + checkInputs = [ nose ]; + + src = fetchPypi { + inherit pname version; + sha256 = "0z35bkk9phs40lf5061k1plhjdl5fskm0dmdikrsqi1bjihnxp8w"; + }; + + checkPhase = '' + nosetests . + ''; + + meta = with stdenv.lib; { + description = "Yet another nose colorer"; + homepage = https://github.com/0compute/yanc; + license = licenses.gpl3; + maintainers = with maintainers; [ jluttine ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index f17e501e9ded..eeab8105de50 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -595,6 +595,8 @@ in { pyparser = callPackage ../development/python-modules/pyparser { }; + pyres = callPackage ../development/python-modules/pyres { }; + pyqt4 = callPackage ../development/python-modules/pyqt/4.x.nix { pythonPackages = self; }; @@ -619,6 +621,8 @@ in { slurm = pkgs.slurm; }; + pyssim = callPackage ../development/python-modules/pyssim { }; + pystache = callPackage ../development/python-modules/pystache { }; pytesseract = callPackage ../development/python-modules/pytesseract { }; @@ -666,6 +670,8 @@ in { relatorio = callPackage ../development/python-modules/relatorio { }; + remotecv = callPackage ../development/python-modules/remotecv { }; + pyzufall = callPackage ../development/python-modules/pyzufall { }; rhpl = disabledIf isPy3k (callPackage ../development/python-modules/rhpl {}); @@ -1146,6 +1152,8 @@ in { cairocffi = callPackage ../development/python-modules/cairocffi {}; + cairosvg1 = callPackage ../development/python-modules/cairosvg/1_x.nix {}; + cairosvg = callPackage ../development/python-modules/cairosvg {}; carrot = callPackage ../development/python-modules/carrot {}; @@ -3080,6 +3088,8 @@ in { nose-exclude = callPackage ../development/python-modules/nose-exclude { }; + nose-focus = callPackage ../development/python-modules/nose-focus { }; + nose2 = callPackage ../development/python-modules/nose2 { }; nose-cover3 = callPackage ../development/python-modules/nose-cover3 { }; @@ -3090,6 +3100,10 @@ in { nose-cprof = callPackage ../development/python-modules/nose-cprof { }; + nose-of-yeti = callPackage ../development/python-modules/nose-of-yeti { }; + + nose-pattern-exclude = callPackage ../development/python-modules/nose-pattern-exclude { }; + nose_warnings_filters = callPackage ../development/python-modules/nose_warnings_filters { }; notebook = callPackage ../development/python-modules/notebook { }; @@ -3857,6 +3871,8 @@ in { simplegeneric = callPackage ../development/python-modules/simplegeneric { }; + should-dsl = callPackage ../development/python-modules/should-dsl { }; + simplejson = callPackage ../development/python-modules/simplejson { }; simplekml = callPackage ../development/python-modules/simplekml { }; @@ -4851,12 +4867,16 @@ in { packaging = callPackage ../development/python-modules/packaging { }; + preggy = callPackage ../development/python-modules/preggy { }; + pytoml = callPackage ../development/python-modules/pytoml { }; pypandoc = callPackage ../development/python-modules/pypandoc { }; yamllint = callPackage ../development/python-modules/yamllint { }; + yanc = callPackage ../development/python-modules/yanc { }; + yarl = callPackage ../development/python-modules/yarl { }; suseapi = callPackage ../development/python-modules/suseapi { };