~aasg/nixexprs

ref: 4b5399b1f065b1ba2703e84ac96827ab9b47c5e7 nixexprs/pkgs/development/python-modules/json-logging/default.nix -rw-r--r-- 1.9 KiB
4b5399b1 — Aluísio Augusto Silva Gonçalves ci: Don't rely on `meta.platforms` being set 4 months ago
                                                                                
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
{ lib
, buildPythonPackage
, fetchFromGitHub
, pytestCheckHook
, wheel
, flask
, connexion
, sanic
, fastapi
, uvicorn
, requests
}:

buildPythonPackage rec {
  pname = "json-logging";
  version = "1.3.0";

  src = fetchFromGitHub {
    owner = "bobbui";
    repo = "json-logging-python";
    rev = version;
    hash = "sha256-0eIhOi30r3ApyVkiBdTQps5tNj7rI+q8TjNWxTnhtMQ=";
  };
  postPatch = ''
    # Fix dependency detection for tests.  `import quart` finds
    # tests/smoketests/quart instead of the quart package.
    sed -i json_logging/framework/quart/__init__.py -r \
      -e 's/^(\s*)import quart$/\1from quart import Quart/'

    # Don't try to find tests in __pycache__.
    substituteInPlace tests/smoketests/test_run_smoketest.py \
      --replace "folder.is_dir()" "folder.is_dir() and folder.name != '__pycache__'"
  '';

  # - Quart is not packaged for Nixpkgs.
  # - FastAPI is broken, see github:NixOS/nixpkgs#112701 and github:tiangolo/fastapi#2335.
  # - Tests for Sanic rely on Request.ctx, introduced in Sanic 19.9.
  checkInputs = [ wheel flask connexion /*quart*/ sanic /*fastapi*/ uvicorn requests pytestCheckHook ];
  disabledTests = [ "quart" "fastapi" ]
    ++ lib.optional (lib.versionOlder sanic.version "19.9.0") "sanic";
  # TODO: replace post NixOS 20.09 with disabledTestPaths
  pytestFlagsArray = [ "--ignore=tests/test_fastapi.py" ];
  # Tests spawn servers and try to connect to them.
  __darwinAllowLocalNetworking = true;

  meta = with lib; {
    description = "JSON Python logging";
    longDescription = ''
      Python logging library to emit JSON log that can be easily indexed and searchable by logging infrastructure such as ELK, EFK, AWS Cloudwatch, GCP Stackdriver.
    '';
    homepage = "https://github.com/bobbui/json-logging-python";
    license = licenses.asl20;
    platforms = platforms.all;
    maintainers = with maintainers; [ AluisioASG ];
  };
}