Add support for local files

This commit is contained in:
Niels Kristian Lyshøj Jensen 2021-07-10 13:38:34 +02:00
parent e40e8ed0e8
commit 2eb8329319
No known key found for this signature in database
GPG key ID: DE3BADFECD31A89D

View file

@ -47,7 +47,8 @@ pythonPackages.callPackage
isSource = source != null; isSource = source != null;
isGit = isSource && source.type == "git"; isGit = isSource && source.type == "git";
isUrl = isSource && source.type == "url"; isUrl = isSource && source.type == "url";
isLocal = isSource && source.type == "directory"; isDirectory = isSource && source.type == "directory";
isFile = isSource && source.type == "file";
isLegacy = isSource && source.type == "legacy"; isLegacy = isSource && source.type == "legacy";
localDepPath = toPath source.url; localDepPath = toPath source.url;
@ -97,7 +98,7 @@ pythonPackages.callPackage
"toml" # Toml is an extra for setuptools-scm "toml" # Toml is an extra for setuptools-scm
]; ];
baseBuildInputs = lib.optional (! lib.elem name skipSetupToolsSCM) pythonPackages.setuptools-scm; baseBuildInputs = lib.optional (! lib.elem name skipSetupToolsSCM) pythonPackages.setuptools-scm;
format = if isLocal || isGit || isUrl then "pyproject" else fileInfo.format; format = if isDirectory || isGit || isUrl then "pyproject" else fileInfo.format;
in in
buildPythonPackage { buildPythonPackage {
pname = moduleName name; pname = moduleName name;
@ -121,7 +122,7 @@ pythonPackages.callPackage
baseBuildInputs baseBuildInputs
++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) pythonPackages.setuptools ++ lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) pythonPackages.setuptools
++ lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg ++ lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg
++ lib.optional isLocal buildSystemPkgs ++ lib.optional isDirectory buildSystemPkgs
++ lib.optional (!__isBootstrap) pythonPackages.poetry ++ lib.optional (!__isBootstrap) pythonPackages.poetry
); );
@ -173,8 +174,10 @@ pythonPackages.callPackage
{ {
inherit (source) url; inherit (source) url;
} }
else if isLocal then else if isDirectory then
(poetryLib.cleanPythonSources { src = localDepPath; }) (poetryLib.cleanPythonSources { src = localDepPath; })
else if isFile then
localDepPath
else if isLegacy then else if isLegacy then
fetchFromLegacy fetchFromLegacy
{ {