1{ lib
2, buildPythonPackage
3, docutils
4, fetchFromGitHub
5, packaging
6, pdm-backend
7, platformdirs
8, pydantic
9, pytestCheckHook
10, pythonOlder
11, sphinx
12, sphinx-autodoc-typehints
13, sphinx-rtd-theme
14, sphinxHook
15, tabulate
16, tomli
17}:
18
19buildPythonPackage rec {
20 pname = "pytoolconfig";
21 version = "1.2.6";
22 format = "pyproject";
23
24 disabled = pythonOlder "3.8";
25
26 src = fetchFromGitHub {
27 owner = "bagel897";
28 repo = "pytoolconfig";
29 rev = "refs/tags/v${version}";
30 hash = "sha256-KmmaxFJbvdOGG9T9iiHKnJpFzZiLVkPJki+qHPxPTdY=";
31 };
32
33 outputs = [
34 "out"
35 "doc"
36 ];
37
38 PDM_PEP517_SCM_VERSION = version;
39
40 nativeBuildInputs = [
41 pdm-backend
42
43 # docs
44 docutils
45 sphinx-autodoc-typehints
46 sphinx-rtd-theme
47 sphinxHook
48 ] ++ passthru.optional-dependencies.doc;
49
50 postPatch = ''
51 substituteInPlace pyproject.toml \
52 --replace "packaging>=22.0" "packaging"
53 '';
54
55 propagatedBuildInputs = [
56 packaging
57 ] ++ lib.optionals (pythonOlder "3.11") [
58 tomli
59 ];
60
61 passthru.optional-dependencies = {
62 validation = [
63 pydantic
64 ];
65 global = [
66 platformdirs
67 ];
68 doc = [
69 sphinx
70 tabulate
71 ];
72 };
73
74 pythonImportsCheck = [
75 "pytoolconfig"
76 ];
77
78 nativeCheckInputs = [
79 pytestCheckHook
80 ] ++ lib.flatten (builtins.attrValues passthru.optional-dependencies);
81
82 meta = with lib; {
83 description = "Python tool configuration";
84 homepage = "https://github.com/bagel897/pytoolconfig";
85 changelog = "https://github.com/bagel897/pytoolconfig/releases/tag/v${version}";
86 license = licenses.lgpl3Plus;
87 maintainers = with maintainers; [ fab hexa ];
88 };
89}