mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 16:51:40 -05:00
Reformat with nixpkgs-fmt 1.0.0
This commit is contained in:
parent
f218d27905
commit
52a484be33
9 changed files with 262 additions and 225 deletions
|
@ -278,7 +278,8 @@ lib.makeScope pkgs.newScope (self: {
|
|||
) { inherit app; };
|
||||
};
|
||||
|
||||
meta = lib.optionalAttrs (lib.hasAttr "description" pyProject.tool.poetry) {
|
||||
meta = lib.optionalAttrs (lib.hasAttr "description" pyProject.tool.poetry)
|
||||
{
|
||||
inherit (pyProject.tool.poetry) description;
|
||||
} // lib.optionalAttrs (lib.hasAttr "homepage" pyProject.tool.poetry) {
|
||||
inherit (pyProject.tool.poetry) homepage;
|
||||
|
|
|
@ -35,7 +35,8 @@ let
|
|||
# See https://docs.python.org/3.8/library/site.html for info on such .pth files
|
||||
# These add another site package path for each line
|
||||
touch poetry2nix-editable.pth
|
||||
${lib.concatMapStringsSep "\n" (src: ''
|
||||
${lib.concatMapStringsSep "\n"
|
||||
(src: ''
|
||||
echo "${toString src}" >> poetry2nix-editable.pth
|
||||
'')
|
||||
(lib.attrValues editablePackageSources)}
|
||||
|
|
|
@ -24,7 +24,8 @@ in
|
|||
pyprojectPatchScript = "${./pyproject-without-path.py}";
|
||||
};
|
||||
} ./remove-path-dependencies.sh
|
||||
) { };
|
||||
)
|
||||
{ };
|
||||
|
||||
pipBuildHook = callPackage
|
||||
(
|
||||
|
@ -37,7 +38,8 @@ in
|
|||
inherit pythonInterpreter pythonSitePackages;
|
||||
};
|
||||
} ./pip-build-hook.sh
|
||||
) { };
|
||||
)
|
||||
{ };
|
||||
|
||||
poetry2nixFixupHook = callPackage
|
||||
(
|
||||
|
@ -47,7 +49,8 @@ in
|
|||
name = "fixup-hook.sh";
|
||||
deps = [ ];
|
||||
} ./fixup-hook.sh
|
||||
) { };
|
||||
)
|
||||
{ };
|
||||
|
||||
# When the "wheel" package itself is a wheel the nixpkgs hook (which pulls in "wheel") leads to infinite recursion
|
||||
# It doesn't _really_ depend on wheel though, it just copies the wheel.
|
||||
|
@ -58,7 +61,8 @@ in
|
|||
name = "wheel-unpack-hook.sh";
|
||||
deps = [ ];
|
||||
} ./wheel-unpack-hook.sh
|
||||
) { };
|
||||
)
|
||||
{ };
|
||||
|
||||
|
||||
}
|
||||
|
|
3
lib.nix
3
lib.nix
|
@ -158,7 +158,8 @@ let
|
|||
+ "Add such a section as described in https://python-poetry.org/docs/pyproject/#poetry-and-pep-517";
|
||||
requires = lib.attrByPath [ "build-system" "requires" ] (throw missingBuildBackendError) pyProject;
|
||||
requiredPkgs = builtins.map (n: lib.elemAt (builtins.match "([^!=<>~\[]+).*" n) 0) requires;
|
||||
in builtins.map (drvAttr: pythonPackages.${drvAttr} or (throw "unsupported build system requirement ${drvAttr}")) requiredPkgs;
|
||||
in
|
||||
builtins.map (drvAttr: pythonPackages.${drvAttr} or (throw "unsupported build system requirement ${drvAttr}")) requiredPkgs;
|
||||
|
||||
# Find gitignore files recursively in parent directory stopping with .git
|
||||
findGitIgnores = path:
|
||||
|
|
|
@ -53,7 +53,9 @@ pythonPackages.callPackage
|
|||
pyProjectPath = localDepPath + "/pyproject.toml";
|
||||
pyProject = poetryLib.readTOML pyProjectPath;
|
||||
in
|
||||
if builtins.pathExists pyProjectPath then poetryLib.getBuildSystemPkgs {
|
||||
if builtins.pathExists pyProjectPath then
|
||||
poetryLib.getBuildSystemPkgs
|
||||
{
|
||||
inherit pythonPackages pyProject;
|
||||
} else [ ];
|
||||
|
||||
|
@ -151,15 +153,18 @@ pythonPackages.callPackage
|
|||
# Interpreters should declare what wheel types they're compatible with (python type + ABI)
|
||||
# Here we can then choose a file based on that info.
|
||||
src =
|
||||
if isGit then (
|
||||
if isGit then
|
||||
(
|
||||
builtins.fetchGit {
|
||||
inherit (source) url;
|
||||
rev = source.reference;
|
||||
ref = sourceSpec.branch or sourceSpec.rev or sourceSpec.tag or "HEAD";
|
||||
}
|
||||
) else if isLocal then (poetryLib.cleanPythonSources { src = localDepPath; }) else fetchFromPypi {
|
||||
) else if isLocal then (poetryLib.cleanPythonSources { src = localDepPath; }) else
|
||||
fetchFromPypi {
|
||||
pname = name;
|
||||
inherit (fileInfo) file hash kind;
|
||||
};
|
||||
}
|
||||
) { }
|
||||
)
|
||||
{ }
|
||||
|
|
|
@ -24,7 +24,8 @@ let
|
|||
|
||||
$ niv modify <package> -a type=tarball -a builtin=true
|
||||
''
|
||||
builtins_fetchTarball { inherit (spec) url sha256; };
|
||||
builtins_fetchTarball
|
||||
{ inherit (spec) url sha256; };
|
||||
fetch_builtin-url = spec:
|
||||
builtins.trace
|
||||
''
|
||||
|
@ -106,7 +107,8 @@ let
|
|||
(
|
||||
name: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
then
|
||||
abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
spec // { outPath = fetch config.pkgs name spec; }
|
||||
|
|
|
@ -89,7 +89,8 @@ self: super:
|
|||
|
||||
cffi =
|
||||
# cffi is bundled with pypy
|
||||
if self.python.implementation == "pypy" then null else (
|
||||
if self.python.implementation == "pypy" then null else
|
||||
(
|
||||
super.cffi.overridePythonAttrs (
|
||||
old: {
|
||||
buildInputs = old.buildInputs ++ [ pkgs.libffi ];
|
||||
|
@ -476,7 +477,8 @@ self: super:
|
|||
);
|
||||
|
||||
molecule =
|
||||
if lib.versionOlder super.molecule.version "3.0.0" then (super.molecule.overridePythonAttrs (
|
||||
if lib.versionOlder super.molecule.version "3.0.0" then
|
||||
(super.molecule.overridePythonAttrs (
|
||||
old: {
|
||||
patches = (old.patches or [ ]) ++ [
|
||||
# Fix build with more recent setuptools versions
|
||||
|
@ -488,7 +490,8 @@ self: super:
|
|||
];
|
||||
buildInputs = old.buildInputs ++ [ self.setuptools-scm-git-archive ];
|
||||
}
|
||||
)) else super.molecule.overridePythonAttrs (old: {
|
||||
)) else
|
||||
super.molecule.overridePythonAttrs (old: {
|
||||
buildInputs = old.buildInputs ++ [ self.setuptools-scm-git-archive ];
|
||||
});
|
||||
|
||||
|
@ -534,7 +537,8 @@ self: super:
|
|||
name = "site.cfg";
|
||||
text = (
|
||||
lib.generators.toINI
|
||||
{ } {
|
||||
{ }
|
||||
{
|
||||
${blasImplementation} = {
|
||||
include_dirs = "${blas}/include";
|
||||
library_dirs = "${blas}/lib";
|
||||
|
@ -594,7 +598,7 @@ self: super:
|
|||
}
|
||||
);
|
||||
|
||||
poetry-core = super.poetry-core.overridePythonAttrs(old: {
|
||||
poetry-core = super.poetry-core.overridePythonAttrs (old: {
|
||||
# "Vendor" dependencies (for build-system support)
|
||||
postPatch = ''
|
||||
echo "import sys" >> poetry/__init__.py
|
||||
|
@ -634,7 +638,9 @@ self: super:
|
|||
);
|
||||
|
||||
pyarrow =
|
||||
if lib.versionAtLeast super.pyarrow.version "0.16.0" then super.pyarrow.overridePythonAttrs (
|
||||
if lib.versionAtLeast super.pyarrow.version "0.16.0" then
|
||||
super.pyarrow.overridePythonAttrs
|
||||
(
|
||||
old:
|
||||
let
|
||||
parseMinor = drv: lib.concatStringsSep "." (lib.take 2 (lib.splitVersion drv.version));
|
||||
|
@ -643,7 +649,8 @@ self: super:
|
|||
# instead of "python". Below we inspect function arguments to maintain compatibilitiy.
|
||||
_arrow-cpp = pkgs.arrow-cpp.override (
|
||||
builtins.intersectAttrs
|
||||
(lib.functionArgs pkgs.arrow-cpp.override) { python = self.python; python3 = self.python; }
|
||||
(lib.functionArgs pkgs.arrow-cpp.override)
|
||||
{ python = self.python; python3 = self.python; }
|
||||
);
|
||||
|
||||
ARROW_HOME = _arrow-cpp;
|
||||
|
@ -682,7 +689,8 @@ self: super:
|
|||
|
||||
dontUseCmakeConfigure = true;
|
||||
}
|
||||
) else super.pyarrow.overridePythonAttrs (
|
||||
) else
|
||||
super.pyarrow.overridePythonAttrs (
|
||||
old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [
|
||||
self.cython
|
||||
|
@ -754,12 +762,14 @@ self: super:
|
|||
-e "/'\/lib\/i386-linux-gnu', '\/lib\/x86_64-linux-gnu']/d" \
|
||||
-e "/\/include\/smpeg/d" \
|
||||
-i buildconfig/config_unix.py
|
||||
${lib.concatMapStrings (dep: ''
|
||||
${lib.concatMapStrings
|
||||
(dep: ''
|
||||
sed \
|
||||
-e "/origincdirs =/a\ origincdirs += ['${lib.getDev dep}/include']" \
|
||||
-e "/origlibdirs =/a\ origlibdirs += ['${lib.getLib dep}/lib']" \
|
||||
-i buildconfig/config_unix.py
|
||||
'') buildInputs
|
||||
'')
|
||||
buildInputs
|
||||
}
|
||||
LOCALBASE=/ ${self.python.interpreter} buildconfig/config.py
|
||||
'';
|
||||
|
@ -1034,7 +1044,8 @@ self: super:
|
|||
);
|
||||
|
||||
shellingham =
|
||||
if lib.versionAtLeast super.shellingham.version "1.3.2" then (
|
||||
if lib.versionAtLeast super.shellingham.version "1.3.2" then
|
||||
(
|
||||
super.shellingham.overridePythonAttrs (
|
||||
old: {
|
||||
format = "pyproject";
|
||||
|
@ -1162,7 +1173,8 @@ self: super:
|
|||
|
||||
zipp = if super.zipp == null then null else
|
||||
(
|
||||
if lib.versionAtLeast super.zipp.version "2.0.0" then (
|
||||
if lib.versionAtLeast super.zipp.version "2.0.0" then
|
||||
(
|
||||
super.zipp.overridePythonAttrs (
|
||||
old: {
|
||||
prePatch = ''
|
||||
|
|
|
@ -71,7 +71,8 @@ let
|
|||
withPython = ver: abi: x: (isPyVersionCompatible ver x.pyVer) && (isPyAbiCompatible abi x.abi);
|
||||
withPlatform =
|
||||
if isLinux
|
||||
then (
|
||||
then
|
||||
(
|
||||
x: x.platform == "manylinux1_${stdenv.platform.kernelArch}"
|
||||
|| x.platform == "manylinux2010_${stdenv.platform.kernelArch}"
|
||||
|| x.platform == "manylinux2014_${stdenv.platform.kernelArch}"
|
||||
|
|
30
pep508.nix
30
pep508.nix
|
@ -8,7 +8,8 @@ let
|
|||
# Strip leading/trailing whitespace from string
|
||||
stripStr = s: lib.elemAt (builtins.split "^ *" (lib.elemAt (builtins.split " *$" s) 0)) 2;
|
||||
findSubExpressionsFun = acc: c: (
|
||||
if c == "(" then (
|
||||
if c == "(" then
|
||||
(
|
||||
let
|
||||
posNew = acc.pos + 1;
|
||||
isOpen = acc.openP == 0;
|
||||
|
@ -20,7 +21,8 @@ let
|
|||
pos = posNew;
|
||||
openP = acc.openP + 1;
|
||||
}
|
||||
) else if c == ")" then (
|
||||
) else if c == ")" then
|
||||
(
|
||||
let
|
||||
openP = acc.openP - 1;
|
||||
exprs = findSubExpressions (substr acc.startPos acc.pos acc.expr);
|
||||
|
@ -122,8 +124,10 @@ let
|
|||
substituteVar
|
||||
];
|
||||
in
|
||||
if builtins.typeOf exprs == "set" then (
|
||||
if exprs.type == "expr" then (
|
||||
if builtins.typeOf exprs == "set" then
|
||||
(
|
||||
if exprs.type == "expr" then
|
||||
(
|
||||
let
|
||||
mVal = ''[a-zA-Z0-9\'"_\. ]+'';
|
||||
mOp = "in|[!=<>]+";
|
||||
|
@ -179,8 +183,10 @@ let
|
|||
builtins.elem (unmarshal x) values;
|
||||
};
|
||||
in
|
||||
if builtins.typeOf exprs == "set" then (
|
||||
if exprs.type == "expr" then (
|
||||
if builtins.typeOf exprs == "set" then
|
||||
(
|
||||
if exprs.type == "expr" then
|
||||
(
|
||||
let
|
||||
expr = exprs;
|
||||
result = (op."${expr.value.op}") (builtins.elemAt expr.value.values 0) (builtins.elemAt expr.value.values 1);
|
||||
|
@ -200,17 +206,21 @@ let
|
|||
"or" = x: y: x || y;
|
||||
};
|
||||
reduceExpressionsFun = acc: v: (
|
||||
if builtins.typeOf v == "set" then (
|
||||
if v.type == "value" then (
|
||||
if builtins.typeOf v == "set" then
|
||||
(
|
||||
if v.type == "value" then
|
||||
(
|
||||
acc // {
|
||||
value = cond."${acc.cond}" acc.value v.value;
|
||||
}
|
||||
) else if v.type == "bool" then (
|
||||
) else if v.type == "bool" then
|
||||
(
|
||||
acc // {
|
||||
cond = v.value;
|
||||
}
|
||||
) else throw "Unsupported type"
|
||||
) else if builtins.typeOf v == "list" then (
|
||||
) else if builtins.typeOf v == "list" then
|
||||
(
|
||||
let
|
||||
ret = builtins.foldl'
|
||||
reduceExpressionsFun
|
||||
|
|
Loading…
Add table
Reference in a new issue