From 98e624eb7d13912435e20cabe8ebaad9fe995a3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= <dev@schuetz-co.de>
Date: Tue, 19 Jan 2021 11:47:13 +0100
Subject: [PATCH] doit: move to pythonPackages

---
 .../doit/default.nix                          | 41 +++++++++++--------
 pkgs/top-level/all-packages.nix               |  2 +-
 pkgs/top-level/python-packages.nix            |  2 +
 3 files changed, 28 insertions(+), 17 deletions(-)
 rename pkgs/development/{tools/build-managers => python-modules}/doit/default.nix (57%)

diff --git a/pkgs/development/tools/build-managers/doit/default.nix b/pkgs/development/python-modules/doit/default.nix
similarity index 57%
rename from pkgs/development/tools/build-managers/doit/default.nix
rename to pkgs/development/python-modules/doit/default.nix
index d48f0d4d56b6..4c27dc7e34c4 100644
--- a/pkgs/development/tools/build-managers/doit/default.nix
+++ b/pkgs/development/python-modules/doit/default.nix
@@ -1,28 +1,38 @@
-{ lib, stdenv, fetchurl, python3Packages }:
+{ lib
+, stdenv
+, fetchPypi
+, buildPythonPackage
+, isPy3k
+, mock
+, pytestCheckHook
+, cloudpickle
+, pyinotify
+, macfsevents
+}:
 
-let
-
-  name = "doit";
+buildPythonPackage rec {
+  pname = "doit";
   version = "0.32.0";
 
-in python3Packages.buildPythonApplication {
-  name = "${name}-${version}";
+  disabled = !isPy3k;
 
-  src = fetchurl {
-    url = "mirror://pypi/d/${name}/${name}-${version}.tar.gz";
+  src = fetchPypi {
+    inherit pname version;
     sha256 = "033m6y9763l81kgqd07rm62bngv3dsm3k9p28nwsn2qawl8h8g9j";
   };
 
-  buildInputs = with python3Packages; [ mock pytest ];
-
-  propagatedBuildInputs = with python3Packages; [ cloudpickle ]
+  propagatedBuildInputs = [ cloudpickle ]
     ++ lib.optional stdenv.isLinux pyinotify
     ++ lib.optional stdenv.isDarwin macfsevents;
 
-  # Tests fail due to mysterious gdbm.open() resource temporarily
-  # unavailable errors.
-  doCheck = false;
-  checkPhase = "py.test";
+  checkInputs = [ mock pytestCheckHook ];
+
+  disabledTests = [
+    # depends on doit-py, which has a circular dependency on doit
+    "test___main__.py"
+    # https://github.com/pydoit/doit/issues/341
+    "test_not_picklable_raises_InvalidTask"
+  ];
 
   meta = with lib; {
     homepage = "https://pydoit.org/";
@@ -36,6 +46,5 @@ in python3Packages.buildPythonApplication {
       available.
     '';
     maintainers = with maintainers; [ pSub ];
-    platforms = platforms.all;
   };
 }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 71ec34213a3f..3f8bf9f1718f 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -11969,7 +11969,7 @@ in
 
   doctl = callPackage ../development/tools/doctl { };
 
-  doit = callPackage ../development/tools/build-managers/doit { };
+  doit = with python3Packages; toPythonApplication doit;
 
   dolt = callPackage ../servers/sql/dolt { };
 
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index 070e855b0c41..f217c1a92ab7 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -1933,6 +1933,8 @@ in {
 
   dogtail = callPackage ../development/python-modules/dogtail { };
 
+  doit = callPackage ../development/python-modules/doit { };
+
   dominate = callPackage ../development/python-modules/dominate { };
 
   dopy = callPackage ../development/python-modules/dopy { };