-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpython.nix
79 lines (71 loc) · 2.21 KB
/
python.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
python3,
zephyr,
bridle,
python-deps,
pyproject-nix,
clang-tools,
gitlint,
lib,
}:
let
# Create a python whose `withPackages` knows about some extra stuff we need
python = python3.override {
self = python;
packageOverrides = final: prev: {
# HACK: Zephyr uses pypi to install non-Python deps
clang-format = clang-tools;
inherit gitlint;
# Extra python packages that aren't in nixpkgs
inherit (python-deps)
bz
doxmlparser
pydebuggerconfig
pyedbglib
pykitinfo
pymcuprog
python-can
sphinx-tsn-theme
sphinxcontrib-svg2pdfconverter
sphinx-csv-filter
;
# WORKAROUND for missing defusedxml in nativeCheckInputs of sphinx-sitemap derivation.
sphinx-sitemap = prev.sphinx-sitemap.overrideAttrs (old: {
pytestCheckPhase = ''true'';
});
};
};
# Parse requirements.txt files into pyproject-nix projects
zephyr-project = pyproject-nix.lib.project.loadRequirementsTxt {
requirements = zephyr + "/scripts/requirements.txt";
};
bridle-project = pyproject-nix.lib.project.loadRequirementsTxt {
requirements = bridle + "/scripts/requirements.txt";
};
# Can't validate the combined packages sets, but we can at least check for
# conflicts within each subset
invalidConstraints =
zephyr-project.validators.validateVersionConstraints { inherit python; }
// bridle-project.validators.validateVersionConstraints { inherit python; };
in
lib.warnIf (invalidConstraints != { })
"pythonEnv: Found invalid Python constraints for: ${builtins.toJSON (lib.attrNames invalidConstraints)}"
(
python.buildEnv.override {
extraLibs =
(bridle-project.renderers.withPackages {
inherit python;
# Nest one project's withPackages within the other to get a combined package
# set. If we want more than two, we should name these lambdas to reduce
# indentation.
extraPackages = (
zephyr-project.renderers.withPackages {
inherit python;
extraPackages = ps: [ ps.west ];
}
);
})
python.pkgs;
ignoreCollisions = true;
}
)