1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchPypi
5, pythonRelaxDepsHook
6, setuptools
7, click
8, requests
9, packaging
10, dparse
11, ruamel-yaml
12, pytestCheckHook
13}:
14
15buildPythonPackage rec {
16 pname = "safety";
17 version = "2.3.5";
18
19 disabled = pythonOlder "3.6";
20
21 format = "pyproject";
22
23 src = fetchPypi {
24 inherit pname version;
25 hash = "sha256-pgwR+JUvQSy7Fl1wyx9nOjtDorqak84R+X5qTeg0qjo=";
26 };
27
28 postPatch = ''
29 substituteInPlace safety/safety.py \
30 --replace "telemetry=True" "telemetry=False"
31 substituteInPlace safety/util.py \
32 --replace "telemetry=True" "telemetry=False"
33 substituteInPlace safety/cli.py \
34 --replace "telemetry', default=True" "telemetry', default=False"
35 '';
36
37 nativeBuildInputs = [
38 pythonRelaxDepsHook
39 setuptools
40 ];
41
42 pythonRelaxDeps = [
43 "packaging"
44 ];
45
46 propagatedBuildInputs = [
47 setuptools
48 click
49 requests
50 packaging
51 dparse
52 ruamel-yaml
53 ];
54
55 nativeCheckInputs = [
56 pytestCheckHook
57 ];
58
59 # Disable tests depending on online services
60 disabledTests = [
61 "test_announcements_if_is_not_tty"
62 "test_check_live"
63 "test_check_live_cached"
64 "test_check_vulnerabilities"
65 "test_license"
66 "test_chained_review"
67 ];
68
69 preCheck = ''
70 export HOME=$(mktemp -d)
71 '';
72
73 meta = with lib; {
74 description = "Checks installed dependencies for known vulnerabilities";
75 homepage = "https://github.com/pyupio/safety";
76 changelog = "https://github.com/pyupio/safety/blob/${version}/CHANGELOG.md";
77 license = licenses.mit;
78 maintainers = with maintainers; [ thomasdesr dotlambda ];
79 };
80}