2019-07-25 17:26:49 -04:00
|
|
|
{ lib
|
2022-07-12 20:39:33 -07:00
|
|
|
, stdenv
|
2019-07-25 17:26:49 -04:00
|
|
|
, buildPythonPackage
|
2022-12-30 20:13:35 +01:00
|
|
|
, autoflake
|
2022-02-17 12:31:55 +01:00
|
|
|
, cython
|
|
|
|
, devtools
|
2022-06-22 23:11:05 +02:00
|
|
|
, email-validator
|
2021-02-28 18:12:20 +01:00
|
|
|
, fetchFromGitHub
|
2020-12-27 16:10:07 +01:00
|
|
|
, pytest-mock
|
2021-02-28 18:12:20 +01:00
|
|
|
, pytestCheckHook
|
|
|
|
, python-dotenv
|
|
|
|
, pythonOlder
|
2022-12-30 20:13:35 +01:00
|
|
|
, pyupgrade
|
2021-02-28 18:12:20 +01:00
|
|
|
, typing-extensions
|
2022-05-29 15:25:41 -04:00
|
|
|
# dependencies for building documentation.
|
2022-07-16 11:56:42 -04:00
|
|
|
# docs fail to build in Darwin sandbox: https://github.com/samuelcolvin/pydantic/issues/4245
|
|
|
|
, withDocs ? (stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.isDarwin)
|
2022-05-29 15:25:41 -04:00
|
|
|
, 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";
|
2022-12-30 20:13:35 +01:00
|
|
|
version = "1.10.4";
|
2022-07-12 20:39:33 -07:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-12-29 13:09:43 -05:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "samuelcolvin";
|
|
|
|
repo = pname;
|
2022-07-16 12:59:26 +02:00
|
|
|
rev = "refs/tags/v${version}";
|
2022-12-30 20:13:35 +01:00
|
|
|
sha256 = "sha256-BFyv1uVq2pLcJeS5955G/pDA3ce9YTqZ6F7kAkwnuvY=";
|
2019-07-25 17:26:49 -04:00
|
|
|
};
|
|
|
|
|
2022-05-29 15:25:41 -04:00
|
|
|
postPatch = ''
|
|
|
|
sed -i '/flake8/ d' Makefile
|
|
|
|
'';
|
|
|
|
|
2022-02-17 12:31:55 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cython
|
2022-07-12 20:39:33 -07:00
|
|
|
] ++ lib.optionals withDocs [
|
2022-05-29 15:25:41 -04:00
|
|
|
# dependencies for building documentation
|
|
|
|
ansi2html
|
|
|
|
markdown-include
|
|
|
|
mdx-truly-sane-lists
|
|
|
|
mkdocs
|
|
|
|
mkdocs-exclude
|
|
|
|
mkdocs-material
|
|
|
|
sqlalchemy
|
|
|
|
ujson
|
|
|
|
orjson
|
|
|
|
hypothesis
|
2022-02-17 12:31:55 +01:00
|
|
|
];
|
|
|
|
|
2019-07-25 17:26:49 -04:00
|
|
|
propagatedBuildInputs = [
|
2022-12-30 20:13:35 +01:00
|
|
|
autoflake
|
2022-02-17 12:31:55 +01:00
|
|
|
devtools
|
2022-06-22 23:11:05 +02:00
|
|
|
email-validator
|
2022-12-30 20:13:35 +01:00
|
|
|
pyupgrade
|
2021-02-28 18:12:20 +01:00
|
|
|
python-dotenv
|
2019-07-25 17:26:49 -04:00
|
|
|
typing-extensions
|
|
|
|
];
|
|
|
|
|
2019-12-29 13:09:43 -05:00
|
|
|
checkInputs = [
|
2020-12-27 16:10:07 +01:00
|
|
|
pytest-mock
|
2021-02-28 18:12:20 +01:00
|
|
|
pytestCheckHook
|
2019-12-29 13:09:43 -05:00
|
|
|
];
|
2019-07-25 17:26:49 -04:00
|
|
|
|
2022-12-30 20:13:35 +01: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
|
|
|
'';
|
|
|
|
|
2022-05-29 15:25:41 -04:00
|
|
|
# Must include current directory into PYTHONPATH, since documentation
|
|
|
|
# building process expects "import pydantic" to work.
|
2022-07-16 11:24:01 -04:00
|
|
|
preBuild = lib.optionalString withDocs ''
|
2022-05-29 15:25:41 -04:00
|
|
|
PYTHONPATH=$PWD:$PYTHONPATH make docs
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Layout documentation in same way as "sphinxHook" does.
|
2022-07-16 11:24:01 -04:00
|
|
|
postInstall = lib.optionalString withDocs ''
|
2022-05-29 15:25:41 -04:00
|
|
|
mkdir -p $out/share/doc/$name
|
|
|
|
mv ./site $out/share/doc/$name/html
|
|
|
|
'';
|
|
|
|
|
2022-04-22 07:27:00 -04:00
|
|
|
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 ];
|
|
|
|
};
|
|
|
|
}
|