1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchpatch,
6 setuptools,
7 strct,
8 pytestCheckHook,
9 pytest-cov-stub,
10 pyyaml,
11}:
12
13buildPythonPackage rec {
14 pname = "birch";
15 version = "0.0.35";
16 pyproject = true;
17
18 src = fetchFromGitHub {
19 owner = "shaypal5";
20 repo = "birch";
21 rev = "v${version}";
22 hash = "sha256-KdQZzQJvJ+logpcLQfaqqEEZJ/9VmNTQX/a4v0oBC98=";
23 };
24
25 patches = [
26 # https://github.com/shaypal5/birch/pull/4
27 (fetchpatch {
28 name = "fix-versioneer-on-python312.patch";
29 url = "https://github.com/shaypal5/birch/commit/84d597b2251ebb76fb15fb70fc86c83baa19dc0b.patch";
30 hash = "sha256-xXADCSIhq1ARny2twzrhR1J8LkMFWFl6tmGxrM8RvkU=";
31 })
32 ];
33
34 postPatch = ''
35 # configure correct version, which fails due to missing .git
36 substituteInPlace versioneer.py birch/_version.py \
37 --replace-fail '"0+unknown"' '"${version}"'
38 '';
39
40 nativeBuildInputs = [ setuptools ];
41
42 dependencies = [ strct ];
43
44 pythonImportsCheck = [
45 "birch"
46 "birch.casters"
47 "birch.exceptions"
48 "birch.paths"
49 ];
50
51 nativeCheckInputs = [
52 pytestCheckHook
53 pytest-cov-stub
54 pyyaml
55 ];
56
57 preCheck = ''
58 export HOME="$(mktemp -d)"
59 '';
60
61 meta = with lib; {
62 description = "Simple hierarchical configuration for Python packages";
63 homepage = "https://github.com/shaypal5/birch";
64 license = licenses.mit;
65 maintainers = with maintainers; [ pbsds ];
66 };
67}