Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, buildPythonPackage 4, autoflake 5, cython 6, devtools 7, email-validator 8, fetchFromGitHub 9, pytest-mock 10, pytestCheckHook 11, python-dotenv 12, pythonAtLeast 13, pythonOlder 14, pyupgrade 15, typing-extensions 16# dependencies for building documentation. 17# docs fail to build in Darwin sandbox: https://github.com/samuelcolvin/pydantic/issues/4245 18, withDocs ? (stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.isDarwin && pythonAtLeast "3.10") 19, ansi2html 20, markdown-include 21, mkdocs 22, mkdocs-exclude 23, mkdocs-material 24, mdx-truly-sane-lists 25, sqlalchemy 26, ujson 27, orjson 28, hypothesis 29, libxcrypt 30}: 31 32buildPythonPackage rec { 33 pname = "pydantic"; 34 version = "1.10.7"; 35 format = "setuptools"; 36 37 outputs = [ 38 "out" 39 ] ++ lib.optionals withDocs [ 40 "doc" 41 ]; 42 43 disabled = pythonOlder "3.7"; 44 45 src = fetchFromGitHub { 46 owner = "samuelcolvin"; 47 repo = pname; 48 rev = "refs/tags/v${version}"; 49 hash = "sha256-7X7rlHJ5Q01CuB9FZzoUfyfwx6AMXtE1BV5t+LnZKIM="; 50 }; 51 52 postPatch = '' 53 sed -i '/flake8/ d' Makefile 54 ''; 55 56 buildInputs = lib.optionals (pythonOlder "3.9") [ 57 libxcrypt 58 ]; 59 60 nativeBuildInputs = [ 61 cython 62 ] ++ lib.optionals withDocs [ 63 # dependencies for building documentation 64 autoflake 65 ansi2html 66 markdown-include 67 mdx-truly-sane-lists 68 mkdocs 69 mkdocs-exclude 70 mkdocs-material 71 sqlalchemy 72 ujson 73 orjson 74 hypothesis 75 ]; 76 77 propagatedBuildInputs = [ 78 devtools 79 pyupgrade 80 typing-extensions 81 ]; 82 83 passthru.optional-dependencies = { 84 dotenv = [ 85 python-dotenv 86 ]; 87 email = [ 88 email-validator 89 ]; 90 }; 91 92 nativeCheckInputs = [ 93 pytest-mock 94 pytestCheckHook 95 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies); 96 97 pytestFlagsArray = [ 98 # https://github.com/pydantic/pydantic/issues/4817 99 "-W" "ignore::pytest.PytestReturnNotNoneWarning" 100 ]; 101 102 preCheck = '' 103 export HOME=$(mktemp -d) 104 ''; 105 106 # Must include current directory into PYTHONPATH, since documentation 107 # building process expects "import pydantic" to work. 108 preBuild = lib.optionalString withDocs '' 109 PYTHONPATH=$PWD:$PYTHONPATH make docs 110 ''; 111 112 # Layout documentation in same way as "sphinxHook" does. 113 postInstall = lib.optionalString withDocs '' 114 mkdir -p $out/share/doc/$name 115 mv ./site $out/share/doc/$name/html 116 ''; 117 118 enableParallelBuilding = true; 119 120 pythonImportsCheck = [ "pydantic" ]; 121 122 meta = with lib; { 123 homepage = "https://github.com/samuelcolvin/pydantic"; 124 description = "Data validation and settings management using Python type hinting"; 125 license = licenses.mit; 126 maintainers = with maintainers; [ wd15 ]; 127 }; 128}