about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/misc/octoprint/default.nix
blob: 3c192c124cbec2409ef521e730274eb6c2f5dd1c (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{ pkgs, stdenv, lib, fetchFromGitHub, python3
# To include additional plugins, pass them here as an overlay.
, packageOverrides ? self: super: {}
}:
let
  mkOverride = attrname: version: sha256:
    self: super: {
      ${attrname} = super.${attrname}.overridePythonAttrs (oldAttrs: {
        inherit version;
        src = oldAttrs.src.override {
          inherit version sha256;
        };
      });
    };

  py = python3.override {
    self = py;
    packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) ([
      (mkOverride "flask"       "0.12.5" "fac2b9d443e49f7e7358a444a3db5950bdd0324674d92ba67f8f1f15f876b14f")
      (mkOverride "flaskbabel"  "0.12.2" "11jwp8vvq1gnm31qh6ihy2h393hy18yn9yjp569g60r0wj1x2sii")
      (mkOverride "tornado"     "4.5.3"  "02jzd23l4r6fswmwxaica9ldlyc2p6q8dk6dyff7j58fmdzf853d")
      (mkOverride "psutil"      "5.6.7"  "ffad8eb2ac614518bbe3c0b8eb9dffdb3a8d2e3a7d5da51c5b974fb723a5c5aa")

      # Octoprint holds back jinja2 to 2.8.1 due to breaking changes.
      # This old version does not have updated test config for pytest 4,
      # and pypi tarball doesn't contain tests dir anyways.
      (self: super: {
        jinja2 = super.jinja2.overridePythonAttrs (oldAttrs: rec {
          version = "2.8.1";
          src = oldAttrs.src.override {
            inherit version;
            sha256 = "14aqmhkc9rw5w0v311jhixdm6ym8vsm29dhyxyrjfqxljwx1yd1m";
          };
          doCheck = false;
        });

        httpretty = super.httpretty.overridePythonAttrs (oldAttrs: rec {
          doCheck = false;
        });

        celery = super.celery.overridePythonAttrs (oldAttrs: rec {
          doCheck = false;
        });
      })
      (self: super: {
        octoprint = self.buildPythonPackage rec {
          pname = "OctoPrint";
          version = "1.4.0";

          src = fetchFromGitHub {
            owner  = "foosel";
            repo   = "OctoPrint";
            rev    = version;
            sha256 = "0387228544v28d69dcdg2zr5gp6qavkfr6dydpjgj5awxv3w25d5";
          };

          propagatedBuildInputs = with super; [
            awesome-slugify flask flask_assets rsa requests pkginfo watchdog
            semantic-version werkzeug flaskbabel tornado
            psutil pyserial flask_login netaddr markdown
            pylru pyyaml sarge feedparser netifaces click websocket_client
            scandir chainmap future wrapt monotonic emoji jinja2
            frozendict cachelib sentry-sdk filetype markupsafe
          ] ++ lib.optionals stdenv.isDarwin [ py.pkgs.appdirs ];

          checkInputs = with super; [ pytestCheckHook mock ddt ];

          postPatch = let
            ignoreVersionConstraints = [
              "sentry-sdk"
            ];
          in ''
            sed -r -i \
              ${lib.concatStringsSep "\n" (map (e:
                ''-e 's@${e}[<>=]+.*@${e}",@g' \''
              ) ignoreVersionConstraints)}
              setup.py
          '';

          dontUseSetuptoolsCheck = true;

          preCheck = ''
            export HOME=$(mktemp -d)
            rm pytest.ini
          '';

          disabledTests = [
            "test_check_setup" # Why should it be able to call pip?
          ] ++ lib.optionals stdenv.isDarwin [
            "test_set_external_modification"
          ];

          passthru.python = self.python;

          meta = with stdenv.lib; {
            homepage = "https://octoprint.org/";
            description = "The snappy web interface for your 3D printer";
            license = licenses.agpl3;
            maintainers = with maintainers; [ abbradar gebner WhittlesJr ];
          };
        };
      })
      (import ./plugins.nix {inherit pkgs;})
      packageOverrides
    ]);
  };
in with py.pkgs; toPythonApplication octoprint