add discoverer for python

This commit is contained in:
DavHau 2022-03-14 10:14:01 +07:00
parent e840c50ec7
commit 753452e0fb

View File

@ -0,0 +1,35 @@
{
dlib,
lib,
subsystem,
}: let
l = lib // builtins;
discover = {tree}: let
subdirProjects =
l.flatten
(l.mapAttrsToList
(dirName: dir: discover {tree = dir;})
(tree.directories or {}));
in
# A directory is identified as a project only if it contains a Cargo.toml
# and a Cargo.lock.
if tree ? files."setup.py"
then
[
(dlib.construct.discoveredProject {
inherit subsystem;
relPath = tree.relPath;
name =
l.unsafeDiscardStringContext
(l.last
(l.splitString "/" (l.removeSuffix "/" "${tree.fullPath}")));
translators = ["pip-WIP"];
subsystemInfo.pythonAttr = "python3";
})
]
++ subdirProjects
else subdirProjects;
in {
inherit discover;
}