1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-03 14:22:35 +03:00
nixpkgs/pkgs/development/python-modules/pydantic/default.nix

115 lines
2.3 KiB
Nix
Raw Normal View History

2019-07-25 17:26:49 -04:00
{ lib
, stdenv
2019-07-25 17:26:49 -04:00
, buildPythonPackage
, autoflake
, cython
, devtools
, email-validator
2021-02-28 18:12:20 +01:00
, fetchFromGitHub
, pytest-mock
2021-02-28 18:12:20 +01:00
, pytestCheckHook
, python-dotenv
, pythonOlder
, pyupgrade
2021-02-28 18:12:20 +01:00
, typing-extensions
# dependencies for building documentation.
# docs fail to build in Darwin sandbox: https://github.com/samuelcolvin/pydantic/issues/4245
, withDocs ? (stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.isDarwin)
, ansi2html
, markdown-include
, mkdocs
, mkdocs-exclude
, mkdocs-material
, mdx-truly-sane-lists
, sqlalchemy
, ujson
, orjson
, hypothesis
2019-07-25 17:26:49 -04:00
}:
buildPythonPackage rec {
pname = "pydantic";
version = "1.10.4";
outputs = [
"out"
] ++ lib.optionals withDocs [
"doc"
];
2021-02-28 18:12:20 +01:00
disabled = pythonOlder "3.7";
2019-07-25 17:26:49 -04:00
src = fetchFromGitHub {
owner = "samuelcolvin";
repo = pname;
rev = "refs/tags/v${version}";
sha256 = "sha256-BFyv1uVq2pLcJeS5955G/pDA3ce9YTqZ6F7kAkwnuvY=";
2019-07-25 17:26:49 -04:00
};
postPatch = ''
sed -i '/flake8/ d' Makefile
'';
nativeBuildInputs = [
cython
] ++ lib.optionals withDocs [
# dependencies for building documentation
ansi2html
markdown-include
mdx-truly-sane-lists
mkdocs
mkdocs-exclude
mkdocs-material
sqlalchemy
ujson
orjson
hypothesis
];
2019-07-25 17:26:49 -04:00
propagatedBuildInputs = [
autoflake
devtools
email-validator
pyupgrade
2021-02-28 18:12:20 +01:00
python-dotenv
2019-07-25 17:26:49 -04:00
typing-extensions
];
checkInputs = [
pytest-mock
2021-02-28 18:12:20 +01:00
pytestCheckHook
];
2019-07-25 17:26:49 -04:00
pytestFlagsArray = [
# https://github.com/pydantic/pydantic/issues/4817
"-W" "ignore::pytest.PytestReturnNotNoneWarning"
];
2021-02-28 18:12:20 +01:00
preCheck = ''
export HOME=$(mktemp -d)
2019-07-25 17:26:49 -04:00
'';
# Must include current directory into PYTHONPATH, since documentation
# building process expects "import pydantic" to work.
preBuild = lib.optionalString withDocs ''
PYTHONPATH=$PWD:$PYTHONPATH make docs
'';
# Layout documentation in same way as "sphinxHook" does.
postInstall = lib.optionalString withDocs ''
mkdir -p $out/share/doc/$name
mv ./site $out/share/doc/$name/html
'';
enableParallelBuilding = true;
2021-02-28 18:12:20 +01:00
pythonImportsCheck = [ "pydantic" ];
2019-07-25 17:26:49 -04:00
meta = with lib; {
homepage = "https://github.com/samuelcolvin/pydantic";
description = "Data validation and settings management using Python type hinting";
license = licenses.mit;
maintainers = with maintainers; [ wd15 ];
};
}