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