Skip to content

Commit

Permalink
mk-poetry-dep: Use wheel platform filtering from pyproject.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
adisbladis committed Nov 1, 2023
1 parent 307f2c4 commit 02b9329
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 406 deletions.
18 changes: 12 additions & 6 deletions mk-poetry-dep.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,23 @@
, ...
}:

let
selectWheel = files: lib.take 1 (builtins.filter (fileEntry: let
isWheelFilName = pyproject-nix.lib.pypa.isWheelFileName fileEntry.file;
file = pyproject-nix.lib.pypa.parseWheelFileName fileEntry.file;
in isWheelFilName && pyproject-nix.lib.pypa.isWheelFileCompatible python file) files);

in

pythonPackages.callPackage
(
{ preferWheel ? preferWheels
, ...
}@args:
let
inherit (python) stdenv;
inherit (pyproject-nix.lib.pypa) normalizePackageName;
inherit (poetryLib) getManyLinuxDeps fetchFromLegacy fetchFromPypi;
inherit (poetryLib) getManyLinuxDeps;

inherit (import ./pep425.nix {
inherit lib python stdenv pyproject-nix;
}) selectWheel
;
fileCandidates =
let
supportedRegex = "^.*(" + builtins.concatStringsSep "|" supportedExtensions + ")";
Expand All @@ -45,6 +48,7 @@ pythonPackages.callPackage
isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname;
in
builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file && isCompatibleEgg f.file) files;

isLocked = lib.length fileCandidates > 0;
isSource = source != null;
isGit = isSource && source.type == "git";
Expand Down Expand Up @@ -73,8 +77,10 @@ pythonPackages.callPackage
isBdist = f: lib.strings.hasSuffix "whl" f.file;
isSdist = f: ! isBdist f && ! isEgg f;
isEgg = f: lib.strings.hasSuffix ".egg" f.file;

binaryDist = selectWheel fileCandidates;
sourceDist = builtins.filter isSdist fileCandidates;

eggs = builtins.filter isEgg fileCandidates;
# 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
Expand Down
135 changes: 0 additions & 135 deletions pep425.nix

This file was deleted.

Loading

0 comments on commit 02b9329

Please sign in to comment.