2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
2022-07-18 16:21:45 +00:00
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPythonPackage
|
2023-01-20 10:41:00 +00:00
|
|
|
, autoflake
|
2022-02-20 05:27:41 +00:00
|
|
|
, cython
|
|
|
|
, devtools
|
2022-06-26 10:26:21 +00:00
|
|
|
, email-validator
|
2021-03-09 03:18:52 +00:00
|
|
|
, fetchFromGitHub
|
2020-12-29 15:07:52 +00:00
|
|
|
, pytest-mock
|
2021-03-09 03:18:52 +00:00
|
|
|
, pytestCheckHook
|
|
|
|
, python-dotenv
|
2023-01-20 10:41:00 +00:00
|
|
|
, pythonAtLeast
|
2021-03-09 03:18:52 +00:00
|
|
|
, pythonOlder
|
2023-01-20 10:41:00 +00:00
|
|
|
, pyupgrade
|
2021-03-09 03:18:52 +00:00
|
|
|
, typing-extensions
|
2022-06-26 10:26:21 +00:00
|
|
|
# dependencies for building documentation.
|
2022-07-18 16:21:45 +00:00
|
|
|
# docs fail to build in Darwin sandbox: https://github.com/samuelcolvin/pydantic/issues/4245
|
2023-01-20 10:41:00 +00:00
|
|
|
, withDocs ? (stdenv.hostPlatform == stdenv.buildPlatform && !stdenv.isDarwin && pythonAtLeast "3.10")
|
2022-06-26 10:26:21 +00:00
|
|
|
, ansi2html
|
|
|
|
, markdown-include
|
|
|
|
, mkdocs
|
|
|
|
, mkdocs-exclude
|
|
|
|
, mkdocs-material
|
|
|
|
, mdx-truly-sane-lists
|
|
|
|
, sqlalchemy
|
|
|
|
, ujson
|
|
|
|
, orjson
|
|
|
|
, hypothesis
|
2023-03-15 16:39:30 +00:00
|
|
|
, libxcrypt
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pydantic";
|
2023-03-15 16:39:30 +00:00
|
|
|
version = "1.10.5";
|
2022-07-18 16:21:45 +00:00
|
|
|
|
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
] ++ lib.optionals withDocs [
|
|
|
|
"doc"
|
|
|
|
];
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "samuelcolvin";
|
|
|
|
repo = pname;
|
2022-08-12 12:06:08 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2023-03-15 16:39:30 +00:00
|
|
|
hash = "sha256-hcjnFqHTQiCIJh7L9JfpHHTm8GEZ+Vac6HO59cbEpWM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
postPatch = ''
|
|
|
|
sed -i '/flake8/ d' Makefile
|
|
|
|
'';
|
|
|
|
|
2023-03-15 16:39:30 +00:00
|
|
|
buildInputs = lib.optionals (pythonOlder "3.9") [
|
|
|
|
libxcrypt
|
|
|
|
];
|
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cython
|
2022-07-18 16:21:45 +00:00
|
|
|
] ++ lib.optionals withDocs [
|
2022-06-26 10:26:21 +00:00
|
|
|
# dependencies for building documentation
|
2023-01-20 10:41:00 +00:00
|
|
|
autoflake
|
2022-06-26 10:26:21 +00:00
|
|
|
ansi2html
|
|
|
|
markdown-include
|
|
|
|
mdx-truly-sane-lists
|
|
|
|
mkdocs
|
|
|
|
mkdocs-exclude
|
|
|
|
mkdocs-material
|
|
|
|
sqlalchemy
|
|
|
|
ujson
|
|
|
|
orjson
|
|
|
|
hypothesis
|
2022-02-20 05:27:41 +00:00
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [
|
2022-02-20 05:27:41 +00:00
|
|
|
devtools
|
2022-06-26 10:26:21 +00:00
|
|
|
email-validator
|
2023-01-20 10:41:00 +00:00
|
|
|
pyupgrade
|
2021-03-09 03:18:52 +00:00
|
|
|
python-dotenv
|
2020-04-24 23:36:52 +00:00
|
|
|
typing-extensions
|
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2020-12-29 15:07:52 +00:00
|
|
|
pytest-mock
|
2021-03-09 03:18:52 +00:00
|
|
|
pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
pytestFlagsArray = [
|
|
|
|
# https://github.com/pydantic/pydantic/issues/4817
|
|
|
|
"-W" "ignore::pytest.PytestReturnNotNoneWarning"
|
|
|
|
];
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME=$(mktemp -d)
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
# Must include current directory into PYTHONPATH, since documentation
|
|
|
|
# building process expects "import pydantic" to work.
|
2022-07-18 16:21:45 +00:00
|
|
|
preBuild = lib.optionalString withDocs ''
|
2022-06-26 10:26:21 +00:00
|
|
|
PYTHONPATH=$PWD:$PYTHONPATH make docs
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Layout documentation in same way as "sphinxHook" does.
|
2022-07-18 16:21:45 +00:00
|
|
|
postInstall = lib.optionalString withDocs ''
|
2022-06-26 10:26:21 +00:00
|
|
|
mkdir -p $out/share/doc/$name
|
|
|
|
mv ./site $out/share/doc/$name/html
|
|
|
|
'';
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
pythonImportsCheck = [ "pydantic" ];
|
|
|
|
|
2020-04-24 23:36:52 +00: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 ];
|
|
|
|
};
|
|
|
|
}
|