1{ lib
2, backoff
3, buildPythonPackage
4, fetchFromGitHub
5, importlib-metadata
6, parameterized
7, poetry-core
8, pytestCheckHook
9, pythonOlder
10, requests
11, requests-mock
12, responses
13, rich
14}:
15
16buildPythonPackage rec {
17 pname = "censys";
18 version = "2.0.9";
19 format = "pyproject";
20
21 disabled = pythonOlder "3.6";
22
23 src = fetchFromGitHub {
24 owner = "censys";
25 repo = "censys-python";
26 rev = "v${version}";
27 sha256 = "sha256-qh3Z8Gza8J3OEM94GguJ+oEdVle01Gx1m/7+LCOErKY=";
28 };
29
30 nativeBuildInputs = [
31 poetry-core
32 ];
33
34 propagatedBuildInputs = [
35 backoff
36 requests
37 rich
38 ] ++ lib.optionals (pythonOlder "3.8") [
39 importlib-metadata
40 ];
41
42 checkInputs = [
43 parameterized
44 pytestCheckHook
45 requests-mock
46 responses
47 ];
48
49 postPatch = ''
50 substituteInPlace pyproject.toml \
51 --replace 'backoff = "^1.11.1"' 'backoff = "*"' \
52 --replace 'requests = ">=2.26.0"' 'requests = "*"' \
53 --replace 'rich = "^10.6.0"' 'rich = "*"'
54 substituteInPlace pytest.ini \
55 --replace "--cov" ""
56 '';
57
58 # The tests want to write a configuration file
59 preCheck = ''
60 export HOME=$(mktemp -d)
61 mkdir -p $HOME
62 '';
63
64 pythonImportsCheck = [ "censys" ];
65
66 meta = with lib; {
67 description = "Python API wrapper for the Censys Search Engine (censys.io)";
68 homepage = "https://github.com/censys/censys-python";
69 license = with licenses; [ asl20 ];
70 maintainers = with maintainers; [ fab ];
71 };
72}