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
|
2023-07-15 17:15:38 +00:00
|
|
|
, fetchpatch
|
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
|
2023-07-15 17:15:38 +00:00
|
|
|
, mike
|
2022-06-26 10:26:21 +00:00
|
|
|
, 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-11-16 04:20:00 +00:00
|
|
|
version = "1.10.12";
|
2023-05-24 13:37:59 +00:00
|
|
|
format = "setuptools";
|
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 {
|
2023-07-15 17:15:38 +00:00
|
|
|
owner = "pydantic";
|
2020-04-24 23:36:52 +00:00
|
|
|
repo = pname;
|
2022-08-12 12:06:08 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-3XnbPGU90wLCPEryFAOky6Iy73Dvgzzh+GbOKW8hZ4U=";
|
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
|
2023-07-15 17:15:38 +00:00
|
|
|
mike
|
2022-06-26 10:26:21 +00:00
|
|
|
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
|
2023-01-20 10:41:00 +00:00
|
|
|
pyupgrade
|
2020-04-24 23:36:52 +00:00
|
|
|
typing-extensions
|
|
|
|
];
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
passthru.optional-dependencies = {
|
|
|
|
dotenv = [
|
|
|
|
python-dotenv
|
|
|
|
];
|
|
|
|
email = [
|
|
|
|
email-validator
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
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
|
2023-05-24 13:37:59 +00:00
|
|
|
] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
|
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; {
|
|
|
|
description = "Data validation and settings management using Python type hinting";
|
2023-07-15 17:15:38 +00:00
|
|
|
homepage = "https://github.com/pydantic/pydantic";
|
|
|
|
changelog = "https://github.com/pydantic/pydantic/blob/v${version}/HISTORY.md";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ wd15 ];
|
|
|
|
};
|
|
|
|
}
|