mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-06 01:31:39 -05:00
fix: disallow the wheel package to preferWheels
Otherwise an infinite recursion error occurs.
This commit is contained in:
parent
1d49746394
commit
ffa5261510
5 changed files with 55 additions and 3 deletions
|
@ -62,6 +62,8 @@ pythonPackages.callPackage
|
|||
inherit pythonPackages pyProject;
|
||||
} else [ ];
|
||||
|
||||
pname = normalizePackageName name;
|
||||
preferWheel' = preferWheel && pname != "wheel";
|
||||
fileInfo =
|
||||
let
|
||||
isBdist = f: lib.strings.hasSuffix "whl" f.file;
|
||||
|
@ -70,7 +72,9 @@ pythonPackages.callPackage
|
|||
binaryDist = selectWheel fileCandidates;
|
||||
sourceDist = builtins.filter isSdist fileCandidates;
|
||||
eggs = builtins.filter isEgg fileCandidates;
|
||||
entries = (if preferWheel then binaryDist ++ sourceDist else sourceDist ++ binaryDist) ++ eggs;
|
||||
# the `wheel` package cannot be built from a wheel, since that requires the wheel package
|
||||
# this causes a circular dependency so we special-case ignore its `preferWheel` attribute value
|
||||
entries = (if preferWheel' then binaryDist ++ sourceDist else sourceDist ++ binaryDist) ++ eggs;
|
||||
lockFileEntry = (
|
||||
if lib.length entries > 0 then builtins.head entries
|
||||
else throw "Missing suitable source/wheel file entry for ${name}"
|
||||
|
@ -95,8 +99,7 @@ pythonPackages.callPackage
|
|||
hooks = python.pkgs.callPackage ./hooks { };
|
||||
in
|
||||
buildPythonPackage {
|
||||
pname = normalizePackageName name;
|
||||
version = version;
|
||||
inherit pname version;
|
||||
|
||||
# Circumvent output separation (https://github.com/NixOS/nixpkgs/pull/190487)
|
||||
format = if format == "pyproject" then "poetry2nix" else format;
|
||||
|
@ -158,6 +161,7 @@ pythonPackages.callPackage
|
|||
|
||||
passthru = {
|
||||
inherit args;
|
||||
preferWheel = preferWheel';
|
||||
};
|
||||
|
||||
# We need to retrieve kind from the interpreter and the filename of the package
|
||||
|
|
|
@ -144,5 +144,6 @@ builtins.removeAttrs
|
|||
test-extras = callTest ./test-extras { };
|
||||
test-no-extras = callTest ./test-no-extras { };
|
||||
missing-iswheel = callTest ./missing-iswheel { };
|
||||
wheel-wheel = callTest ./wheel-wheel { };
|
||||
}
|
||||
skipTests
|
||||
|
|
13
tests/wheel-wheel/default.nix
Normal file
13
tests/wheel-wheel/default.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ lib, poetry2nix, python3, runCommand }:
|
||||
let
|
||||
env = poetry2nix.mkPoetryEnv {
|
||||
python = python3;
|
||||
pyproject = ./pyproject.toml;
|
||||
poetrylock = ./poetry.lock;
|
||||
preferWheels = true;
|
||||
};
|
||||
isWheelWheel = env.python.pkgs.wheel.src.isWheel;
|
||||
in
|
||||
assert (!isWheelWheel); runCommand "wheel-wheel-test" { } ''
|
||||
${env}/bin/python -c 'import wheel; print(wheel.__version__)' > $out
|
||||
''
|
21
tests/wheel-wheel/poetry.lock
generated
Normal file
21
tests/wheel-wheel/poetry.lock
generated
Normal file
|
@ -0,0 +1,21 @@
|
|||
# This file is automatically @generated by Poetry and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "wheel"
|
||||
version = "0.38.4"
|
||||
description = "A built-package format for Python"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "wheel-0.38.4-py3-none-any.whl", hash = "sha256:b60533f3f5d530e971d6737ca6d58681ee434818fab630c83a734bb10c083ce8"},
|
||||
{file = "wheel-0.38.4.tar.gz", hash = "sha256:965f5259b566725405b05e7cf774052044b1ed30119b5d586b2703aafe8719ac"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
test = ["pytest (>=3.0.0)"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.9"
|
||||
content-hash = "30c70d03c6714b9b24b7684eb669096a9efaaadff29fbb8e811d92f4a990853f"
|
13
tests/wheel-wheel/pyproject.toml
Normal file
13
tests/wheel-wheel/pyproject.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[tool.poetry]
|
||||
name = "test-wheel-wheel"
|
||||
version = "0.1.0"
|
||||
description = "Test of python wheel-wheel package"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.9"
|
||||
wheel = "^0.38.4"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1"]
|
||||
build-backend = "poetry.core.masonry.api"
|
Loading…
Add table
Reference in a new issue