1{ lib, buildPythonPackage, fetchPypi, setuptools, isPy27, futures
2, backports_functools_lru_cache, mock, pytest
3}:
4
5let
6 skipTests = [ "test_requirements_finder" "test_pipfile_finder" ] ++ lib.optional isPy27 "test_standard_library_deprecates_user_issue_778";
7 testOpts = lib.concatMapStringsSep " " (t: "--deselect test_isort.py::${t}") skipTests;
8in buildPythonPackage rec {
9 pname = "isort";
10 version = "4.3.21"; # Note 4.x is the last version that supports Python2
11
12 src = fetchPypi {
13 inherit pname version;
14 sha256 = "54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1";
15 };
16
17 propagatedBuildInputs = [
18 setuptools
19 ] ++ lib.optionals isPy27 [ futures backports_functools_lru_cache ];
20
21 checkInputs = [ mock pytest ];
22
23 checkPhase = ''
24 # isort excludes paths that contain /build/, so test fixtures don't work
25 # with TMPDIR=/build/
26 PATH=$out/bin:$PATH TMPDIR=/tmp/ pytest ${testOpts}
27
28 # Confirm that the produced executable script is wrapped correctly and runs
29 # OK, by launching it in a subshell without PYTHONPATH
30 (
31 unset PYTHONPATH
32 echo "Testing that `isort --version-number` returns OK..."
33 $out/bin/isort --version-number
34 )
35 '';
36
37 meta = with lib; {
38 description = "A Python utility / library to sort Python imports";
39 homepage = "https://github.com/timothycrosley/isort";
40 license = licenses.mit;
41 maintainers = with maintainers; [ couchemar nand0p ];
42 };
43}