summary refs log tree commit diff
path: root/pkgs/development/python-modules/isort/default.nix
blob: b2ef4e66f3611ae23cccac7c7ca0dce9ce0da57a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ lib, buildPythonPackage, fetchPypi, setuptools, isPy27, futures
, backports_functools_lru_cache, mock, pytest
}:

let
  skipTests = [ "test_requirements_finder" "test_pipfile_finder" ] ++ lib.optional isPy27 "test_standard_library_deprecates_user_issue_778";
  testOpts = lib.concatMapStringsSep " " (t: "--deselect test_isort.py::${t}") skipTests;
in buildPythonPackage rec {
  pname = "isort";
  version = "4.3.21"; # Note 4.x is the last version that supports Python2

  src = fetchPypi {
    inherit pname version;
    sha256 = "54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1";
  };

  propagatedBuildInputs = [
    setuptools
  ] ++ lib.optionals isPy27 [ futures backports_functools_lru_cache ];

  checkInputs = [ mock pytest ];

  checkPhase = ''
    # isort excludes paths that contain /build/, so test fixtures don't work
    # with TMPDIR=/build/
    PATH=$out/bin:$PATH TMPDIR=/tmp/ pytest ${testOpts}

    # Confirm that the produced executable script is wrapped correctly and runs
    # OK, by launching it in a subshell without PYTHONPATH
    (
      unset PYTHONPATH
      echo "Testing that `isort --version-number` returns OK..."
      $out/bin/isort --version-number
    )
  '';

  meta = with lib; {
    description = "A Python utility / library to sort Python imports";
    homepage = "https://github.com/timothycrosley/isort";
    license = licenses.mit;
    maintainers = with maintainers; [ couchemar nand0p ];
  };
}