nixpkgs-fmt broke it's format yet again

This commit is contained in:
adisbladis 2020-04-29 14:12:59 +01:00
parent 807ab61e94
commit 4ebbfdacd1
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7
25 changed files with 1367 additions and 1319 deletions

View file

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} { pkgs ? import <nixpkgs> { }
, lib ? pkgs.lib , lib ? pkgs.lib
, version , version
}: }:
@ -33,8 +33,8 @@ pkgs.stdenv.mkDerivation {
mv poetry2nix $out/bin mv poetry2nix $out/bin
wrapProgram $out/bin/poetry2nix --prefix PATH ":" ${lib.makeBinPath [ wrapProgram $out/bin/poetry2nix --prefix PATH ":" ${lib.makeBinPath [
pkgs.nix-prefetch-git pkgs.nix-prefetch-git
]} ]}
runHook postInstall runHook postInstall
''; '';

View file

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} { pkgs ? import <nixpkgs> { }
, lib ? pkgs.lib , lib ? pkgs.lib
, poetry ? null , poetry ? null
, poetryLib ? import ./lib.nix { inherit lib pkgs; } , poetryLib ? import ./lib.nix { inherit lib pkgs; }
@ -11,12 +11,10 @@ let
/* The default list of poetry2nix override overlays */ /* The default list of poetry2nix override overlays */
defaultPoetryOverrides = (import ./overrides.nix { inherit pkgs lib; }); defaultPoetryOverrides = (import ./overrides.nix { inherit pkgs lib; });
mkEvalPep508 = import ./pep508.nix { mkEvalPep508 = import ./pep508.nix {
inherit lib poetryLib; inherit lib poetryLib;
stdenv = pkgs.stdenv; stdenv = pkgs.stdenv;
}; };
getFunctorFn = fn: if builtins.typeOf fn == "set" then fn.__functor else fn; getFunctorFn = fn: if builtins.typeOf fn == "set" then fn.__functor else fn;
# Map SPDX identifiers to license names # Map SPDX identifiers to license names
@ -36,78 +34,80 @@ let
, pwd ? projectDir , pwd ? projectDir
, preferWheels ? false , preferWheels ? false
}@attrs: }@attrs:
let let
poetryPkg = poetry.override { inherit python; }; poetryPkg = poetry.override { inherit python; };
pyProject = readTOML pyproject;
pyProject = readTOML pyproject; poetryLock = readTOML poetrylock;
poetryLock = readTOML poetrylock; lockFiles =
lockFiles = let let
lockfiles = lib.getAttrFromPath [ "metadata" "files" ] poetryLock; lockfiles = lib.getAttrFromPath [ "metadata" "files" ] poetryLock;
in lib.listToAttrs (lib.mapAttrsToList (n: v: { name = moduleName n; value = v; }) lockfiles); in
lib.listToAttrs (lib.mapAttrsToList (n: v: { name = moduleName n; value = v; }) lockfiles);
specialAttrs = [
"overrides"
"poetrylock"
"projectDir"
"pwd"
"preferWheels"
];
passedAttrs = builtins.removeAttrs attrs specialAttrs;
evalPep508 = mkEvalPep508 python;
specialAttrs = [ # Filter packages by their PEP508 markers & pyproject interpreter version
"overrides" partitions =
"poetrylock" let
"projectDir"
"pwd"
"preferWheels"
];
passedAttrs = builtins.removeAttrs attrs specialAttrs;
evalPep508 = mkEvalPep508 python;
# Filter packages by their PEP508 markers & pyproject interpreter version
partitions = let
supportsPythonVersion = pkgMeta: if pkgMeta ? marker then (evalPep508 pkgMeta.marker) else true; supportsPythonVersion = pkgMeta: if pkgMeta ? marker then (evalPep508 pkgMeta.marker) else true;
in in
lib.partition supportsPythonVersion poetryLock.package; lib.partition supportsPythonVersion poetryLock.package;
compatible = partitions.right;
incompatible = partitions.wrong;
compatible = partitions.right; # Create an overriden version of pythonPackages
incompatible = partitions.wrong; #
# We need to avoid mixing multiple versions of pythonPackages in the same
# Create an overriden version of pythonPackages # closure as python can only ever have one version of a dependency
# baseOverlay = self: super:
# We need to avoid mixing multiple versions of pythonPackages in the same let
# closure as python can only ever have one version of a dependency getDep = depName: self.${depName};
baseOverlay = self: super: lockPkgs = builtins.listToAttrs
let (
getDep = depName: self.${depName}; builtins.map
(
lockPkgs = builtins.listToAttrs ( pkgMeta: rec {
builtins.map ( name = moduleName pkgMeta.name;
pkgMeta: rec { value = self.mkPoetryDep
name = moduleName pkgMeta.name; (
value = self.mkPoetryDep ( pkgMeta // {
pkgMeta // { inherit pwd preferWheels;
inherit pwd preferWheels; source = pkgMeta.source or null;
source = pkgMeta.source or null; files = lockFiles.${name};
files = lockFiles.${name}; pythonPackages = self;
pythonPackages = self; sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name};
sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name}; }
} );
); }
} ) compatible
) compatible
); );
in in
lockPkgs; lockPkgs;
overlays = builtins.map getFunctorFn ( overlays = builtins.map getFunctorFn
(
[ [
( (
self: super: self: super:
let let
hooks = self.callPackage ./hooks {}; hooks = self.callPackage ./hooks { };
in in
{ {
mkPoetryDep = self.callPackage ./mk-poetry-dep.nix { mkPoetryDep = self.callPackage ./mk-poetry-dep.nix {
inherit pkgs lib python poetryLib; inherit pkgs lib python poetryLib;
}; };
poetry = poetryPkg; poetry = poetryPkg;
# The canonical name is setuptools-scm # The canonical name is setuptools-scm
setuptools-scm = super.setuptools_scm; setuptools-scm = super.setuptools_scm;
inherit (hooks) pipBuildHook removePathDependenciesHook poetry2nixFixupHook; inherit (hooks) pipBuildHook removePathDependenciesHook poetry2nixFixupHook;
} }
) )
# Null out any filtered packages, we don't want python.pkgs from nixpkgs # Null out any filtered packages, we don't want python.pkgs from nixpkgs
(self: super: builtins.listToAttrs (builtins.map (x: { name = moduleName x.name; value = null; }) incompatible)) (self: super: builtins.listToAttrs (builtins.map (x: { name = moduleName x.name; value = null; }) incompatible))
@ -116,17 +116,15 @@ let
] ++ # User provided overrides ] ++ # User provided overrides
overrides overrides
); );
packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) overlays;
packageOverrides = lib.foldr lib.composeExtensions (self: super: {}) overlays; py = python.override { inherit packageOverrides; self = py; };
in
py = python.override { inherit packageOverrides; self = py; }; {
in python = py;
{ poetryPackages = map (pkg: py.pkgs.${moduleName pkg.name}) compatible;
python = py; poetryLock = poetryLock;
poetryPackages = map (pkg: py.pkgs.${moduleName pkg.name}) compatible; inherit pyProject;
poetryLock = poetryLock; };
inherit pyProject;
};
/* Returns a package with a python interpreter and all packages specified in the poetry.lock lock file. /* Returns a package with a python interpreter and all packages specified in the poetry.lock lock file.
@ -142,14 +140,15 @@ let
, python ? pkgs.python3 , python ? pkgs.python3
, preferWheels ? false , preferWheels ? false
}: }:
let let
py = mkPoetryPackages ( py = mkPoetryPackages
(
{ {
inherit pyproject poetrylock overrides python pwd preferWheels; inherit pyproject poetrylock overrides python pwd preferWheels;
} }
); );
in in
py.python.withPackages (_: py.poetryPackages); py.python.withPackages (_: py.poetryPackages);
/* Creates a Python application from pyproject.toml and poetry.lock */ /* Creates a Python application from pyproject.toml and poetry.lock */
mkPoetryApplication = mkPoetryApplication =
@ -158,81 +157,79 @@ let
, pyproject ? projectDir + "/pyproject.toml" , pyproject ? projectDir + "/pyproject.toml"
, poetrylock ? projectDir + "/poetry.lock" , poetrylock ? projectDir + "/poetry.lock"
, overrides ? [ defaultPoetryOverrides ] , overrides ? [ defaultPoetryOverrides ]
, meta ? {} , meta ? { }
, python ? pkgs.python3 , python ? pkgs.python3
, pwd ? projectDir , pwd ? projectDir
, preferWheels ? false , preferWheels ? false
, ... , ...
}@attrs: }@attrs:
let let
poetryPython = mkPoetryPackages { poetryPython = mkPoetryPackages {
inherit pyproject poetrylock overrides python pwd preferWheels; inherit pyproject poetrylock overrides python pwd preferWheels;
}; };
py = poetryPython.python; py = poetryPython.python;
inherit (poetryPython) pyProject; inherit (poetryPython) pyProject;
specialAttrs = [
"overrides"
"poetrylock"
"projectDir"
"pwd"
"pyproject"
"preferWheels"
];
passedAttrs = builtins.removeAttrs attrs specialAttrs;
specialAttrs = [ # Get dependencies and filter out depending on interpreter version
"overrides" getDeps = depAttr:
"poetrylock" let
"projectDir" compat = isCompatible (poetryLib.getPythonVersion py);
"pwd" deps = pyProject.tool.poetry.${depAttr} or { };
"pyproject" depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
"preferWheels" in
]; builtins.map
passedAttrs = builtins.removeAttrs attrs specialAttrs; (
dep:
let
pkg = py.pkgs."${dep}";
constraints = deps.${dep}.python or "";
isCompat = compat constraints;
in if isCompat then pkg else null
) depAttrs;
getInputs = attr: attrs.${attr} or [ ];
mkInput = attr: extraInputs: getInputs attr ++ extraInputs;
buildSystemPkgs = poetryLib.getBuildSystemPkgs {
inherit pyProject;
pythonPackages = py.pkgs;
};
in
py.pkgs.buildPythonApplication
(
passedAttrs // {
pname = moduleName pyProject.tool.poetry.name;
version = pyProject.tool.poetry.version;
# Get dependencies and filter out depending on interpreter version inherit src;
getDeps = depAttr:
let
compat = isCompatible (poetryLib.getPythonVersion py);
deps = pyProject.tool.poetry.${depAttr} or {};
depAttrs = builtins.map (d: lib.toLower d) (builtins.attrNames deps);
in
builtins.map (
dep:
let
pkg = py.pkgs."${dep}";
constraints = deps.${dep}.python or "";
isCompat = compat constraints;
in
if isCompat then pkg else null
) depAttrs;
getInputs = attr: attrs.${attr} or []; format = "pyproject";
mkInput = attr: extraInputs: getInputs attr ++ extraInputs;
buildSystemPkgs = poetryLib.getBuildSystemPkgs { buildInputs = mkInput "buildInputs" buildSystemPkgs;
inherit pyProject; propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ py.pkgs.setuptools ]);
pythonPackages = py.pkgs; nativeBuildInputs = mkInput "nativeBuildInputs" [ pkgs.yj py.pkgs.removePathDependenciesHook ];
}; checkInputs = mkInput "checkInputs" (getDeps "dev-dependencies");
in
py.pkgs.buildPythonApplication (
passedAttrs // {
pname = moduleName pyProject.tool.poetry.name;
version = pyProject.tool.poetry.version;
inherit src; passthru = {
python = py;
};
format = "pyproject"; meta = meta // {
inherit (pyProject.tool.poetry) description homepage;
inherit (py.meta) platforms;
license = getLicenseBySpdxId (pyProject.tool.poetry.license or "unknown");
};
buildInputs = mkInput "buildInputs" buildSystemPkgs; }
propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ py.pkgs.setuptools ]); );
nativeBuildInputs = mkInput "nativeBuildInputs" [ pkgs.yj py.pkgs.removePathDependenciesHook ];
checkInputs = mkInput "checkInputs" (getDeps "dev-dependencies");
passthru = {
python = py;
};
meta = meta // {
inherit (pyProject.tool.poetry) description homepage;
inherit (py.meta) platforms;
license = getLicenseBySpdxId (pyProject.tool.poetry.license or "unknown");
};
}
);
/* Poetry2nix CLI used to supplement SHA-256 hashes for git dependencies */ /* Poetry2nix CLI used to supplement SHA-256 hashes for git dependencies */
cli = import ./cli.nix { inherit pkgs lib version; }; cli = import ./cli.nix { inherit pkgs lib version; };
@ -254,7 +251,7 @@ in
defaultSet = defaultPoetryOverrides self super; defaultSet = defaultPoetryOverrides self super;
customSet = fn self super; customSet = fn self super;
in in
defaultSet // customSet; defaultSet // customSet;
}; };
/* /*

View file

@ -9,24 +9,26 @@
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ]; systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
# Memoize nixpkgs for different platforms for efficiency. # Memoize nixpkgs for different platforms for efficiency.
nixpkgsFor = forAllSystems ( nixpkgsFor = forAllSystems
system: (
system:
import nixpkgs { import nixpkgs {
inherit system; inherit system;
overlays = [ self.overlay ]; overlays = [ self.overlay ];
} }
); );
in in
{ {
overlay = import ./overlay.nix; overlay = import ./overlay.nix;
# TODO: I feel like `packages` is the wrong place for the poetry2nix attr # TODO: I feel like `packages` is the wrong place for the poetry2nix attr
packages = forAllSystems ( packages = forAllSystems
(
system: { system: {
inherit (nixpkgsFor.${system}) poetry poetry2nix; inherit (nixpkgsFor.${system}) poetry poetry2nix;
} }
); );
}; };
} }

View file

@ -11,21 +11,23 @@ let
in in
{ {
removePathDependenciesHook = callPackage ( removePathDependenciesHook = callPackage
{}: (
{}:
makeSetupHook { makeSetupHook {
name = "remove-path-dependencies.sh"; name = "remove-path-dependencies.sh";
deps = []; deps = [ ];
substitutions = { substitutions = {
inherit pythonInterpreter; inherit pythonInterpreter;
yj = "${yj}/bin/yj"; yj = "${yj}/bin/yj";
pyprojectPatchScript = "${./pyproject-without-path.py}"; pyprojectPatchScript = "${./pyproject-without-path.py}";
}; };
} ./remove-path-dependencies.sh } ./remove-path-dependencies.sh
) {}; ) { };
pipBuildHook = callPackage ( pipBuildHook = callPackage
{ pip, wheel }: (
{ pip, wheel }:
makeSetupHook { makeSetupHook {
name = "pip-build-hook.sh"; name = "pip-build-hook.sh";
deps = [ pip wheel ]; deps = [ pip wheel ];
@ -33,14 +35,15 @@ in
inherit pythonInterpreter pythonSitePackages; inherit pythonInterpreter pythonSitePackages;
}; };
} ./pip-build-hook.sh } ./pip-build-hook.sh
) {}; ) { };
poetry2nixFixupHook = callPackage ( poetry2nixFixupHook = callPackage
{}: (
{}:
makeSetupHook { makeSetupHook {
name = "fixup-hook.sh"; name = "fixup-hook.sh";
deps = []; deps = [ ];
} ./fixup-hook.sh } ./fixup-hook.sh
) {}; ) { };
} }

122
lib.nix
View file

@ -12,13 +12,15 @@ let
moduleName = name: lib.toLower (lib.replaceStrings [ "_" "." ] [ "-" "-" ] name); moduleName = name: lib.toLower (lib.replaceStrings [ "_" "." ] [ "-" "-" ] name);
# Get a full semver pythonVersion from a python derivation # Get a full semver pythonVersion from a python derivation
getPythonVersion = python: let getPythonVersion = python:
pyVer = lib.splitVersion python.pythonVersion ++ [ "0" ]; let
ver = lib.splitVersion python.version; pyVer = lib.splitVersion python.pythonVersion ++ [ "0" ];
major = l: lib.elemAt l 0; ver = lib.splitVersion python.version;
minor = l: lib.elemAt l 1; major = l: lib.elemAt l 0;
joinVersion = v: lib.concatStringsSep "." v; minor = l: lib.elemAt l 1;
in joinVersion (if major pyVer == major ver && minor pyVer == minor ver then ver else pyVer); joinVersion = v: lib.concatStringsSep "." v;
in
joinVersion ( if major pyVer == major ver && minor pyVer == minor ver then ver else pyVer);
# Compare a semver expression with a version # Compare a semver expression with a version
isCompatible = version: isCompatible = version:
@ -30,41 +32,41 @@ let
}; };
splitRe = "(" + (builtins.concatStringsSep "|" (builtins.map (x: lib.replaceStrings [ "|" ] [ "\\|" ] x) (lib.attrNames operators))) + ")"; splitRe = "(" + (builtins.concatStringsSep "|" (builtins.map (x: lib.replaceStrings [ "|" ] [ "\\|" ] x) (lib.attrNames operators))) + ")";
in in
expr: expr:
let
tokens = builtins.filter (x: x != "") (builtins.split splitRe expr);
combine = acc: v:
let let
tokens = builtins.filter (x: x != "") (builtins.split splitRe expr); isOperator = builtins.typeOf v == "list";
combine = acc: v: operator = if isOperator then (builtins.elemAt v 0) else acc.operator;
let
isOperator = builtins.typeOf v == "list";
operator = if isOperator then (builtins.elemAt v 0) else acc.operator;
in
if isOperator then (acc // { inherit operator; }) else {
inherit operator;
state = operators."${operator}" acc.state (satisfiesSemver version v);
};
initial = { operator = "&&"; state = true; };
in in
if expr == "" then true else (builtins.foldl' combine initial tokens).state; if isOperator then (acc // { inherit operator; }) else {
inherit operator;
state = operators."${operator}" acc.state (satisfiesSemver version v);
};
initial = { operator = "&&"; state = true; };
in if expr == "" then true else (builtins.foldl' combine initial tokens).state;
fromTOML = builtins.fromTOML or fromTOML = builtins.fromTOML or
( (
toml: builtins.fromJSON ( toml: builtins.fromJSON
builtins.readFile ( (
pkgs.runCommand "from-toml" builtins.readFile
{ (
inherit toml; pkgs.runCommand "from-toml"
allowSubstitutes = false; {
preferLocalBuild = true; inherit toml;
} allowSubstitutes = false;
'' preferLocalBuild = true;
${pkgs.remarshal}/bin/remarshal \ }
-if toml \ ''
-i <(echo "$toml") \ ${pkgs.remarshal}/bin/remarshal \
-of json \ -if toml \
-o $out -i <(echo "$toml") \
'' -of json \
-o $out
''
)
) )
)
); );
readTOML = path: fromTOML (builtins.readFile path); readTOML = path: fromTOML (builtins.readFile path);
@ -75,10 +77,10 @@ let
let let
ml = pkgs.pythonManylinuxPackages; ml = pkgs.pythonManylinuxPackages;
in in
if lib.strings.hasInfix "manylinux1" f then { pkg = [ ml.manylinux1 ]; str = "1"; } if lib.strings.hasInfix "manylinux1" f then { pkg = [ ml.manylinux1 ]; str = "1"; }
else if lib.strings.hasInfix "manylinux2010" f then { pkg = [ ml.manylinux2010 ]; str = "2010"; } else if lib.strings.hasInfix "manylinux2010" f then { pkg = [ ml.manylinux2010 ]; str = "2010"; }
else if lib.strings.hasInfix "manylinux2014" f then { pkg = [ ml.manylinux2014 ]; str = "2014"; } else if lib.strings.hasInfix "manylinux2014" f then { pkg = [ ml.manylinux2014 ]; str = "2014"; }
else { pkg = []; str = null; }; else { pkg = [ ]; str = null; };
# Fetch the artifacts from the PyPI index. Since we get all # Fetch the artifacts from the PyPI index. Since we get all
# info we need from the lock file we don't use nixpkgs' fetchPyPi # info we need from the lock file we don't use nixpkgs' fetchPyPi
@ -90,25 +92,25 @@ let
# file: filename including extension # file: filename including extension
# hash: SRI hash # hash: SRI hash
# kind: Language implementation and version tag https://www.python.org/dev/peps/pep-0427/#file-name-convention # kind: Language implementation and version tag https://www.python.org/dev/peps/pep-0427/#file-name-convention
fetchFromPypi = lib.makeOverridable ( fetchFromPypi = lib.makeOverridable
{ pname, file, hash, kind }: (
{ pname, file, hash, kind }:
pkgs.fetchurl { pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/${kind}/${lib.toLower (builtins.substring 0 1 file)}/${pname}/${file}"; url = "https://files.pythonhosted.org/packages/${kind}/${lib.toLower (builtins.substring 0 1 file)}/${pname}/${file}";
inherit hash; inherit hash;
} }
); );
getBuildSystemPkgs = getBuildSystemPkgs =
{ pythonPackages { pythonPackages
, pyProject , pyProject
}: }:
let let
buildSystem = lib.attrByPath [ "build-system" "build-backend" ] "" pyProject; buildSystem = lib.attrByPath [ "build-system" "build-backend" ] "" pyProject;
drvAttr = moduleName (builtins.elemAt (builtins.split "\\.|:" buildSystem) 0); drvAttr = moduleName (builtins.elemAt (builtins.split "\\.|:" buildSystem) 0);
in in
if buildSystem == "" then [] else ( if buildSystem == "" then [ ] else (
[ pythonPackages.${drvAttr} or (throw "unsupported build system ${buildSystem}") ] [ pythonPackages.${drvAttr} or (throw "unsupported build system ${buildSystem}") ]
); );
# Find gitignore files recursively in parent directory stopping with .git # Find gitignore files recursively in parent directory stopping with .git
findGitIgnores = path: findGitIgnores = path:
@ -117,9 +119,9 @@ let
gitIgnore = path + "/.gitignore"; gitIgnore = path + "/.gitignore";
isGitRoot = builtins.pathExists (path + "/.git"); isGitRoot = builtins.pathExists (path + "/.git");
hasGitIgnore = builtins.pathExists gitIgnore; hasGitIgnore = builtins.pathExists gitIgnore;
gitIgnores = if hasGitIgnore then [ gitIgnore ] else []; gitIgnores = if hasGitIgnore then [ gitIgnore ] else [ ];
in in
lib.optionals (builtins.toString path != "/" && ! isGitRoot) (findGitIgnores parent) ++ gitIgnores; lib.optionals (builtins.toString path != "/" && ! isGitRoot) (findGitIgnores parent) ++ gitIgnores;
/* /*
Provides a source filtering mechanism that: Provides a source filtering mechanism that:
@ -136,13 +138,13 @@ let
|| (type == "regular" && ! lib.strings.hasSuffix ".pyc" name) || (type == "regular" && ! lib.strings.hasSuffix ".pyc" name)
; ;
in in
lib.cleanSourceWith { lib.cleanSourceWith {
filter = lib.cleanSourceFilter; filter = lib.cleanSourceFilter;
src = lib.cleanSourceWith { src = lib.cleanSourceWith {
filter = pkgs.nix-gitignore.gitignoreFilterPure pycacheFilter gitIgnores src; filter = pkgs.nix-gitignore.gitignoreFilterPure pycacheFilter gitIgnores src;
inherit src; inherit src;
};
}; };
};
in in
{ {
inherit inherit

View file

@ -10,7 +10,7 @@
, version , version
, files , files
, source , source
, dependencies ? {} , dependencies ? { }
, pythonPackages , pythonPackages
, python-versions , python-versions
, pwd , pwd
@ -20,10 +20,11 @@
, ... , ...
}: }:
pythonPackages.callPackage ( pythonPackages.callPackage
{ preferWheel ? preferWheels (
, ... { preferWheel ? preferWheels
}@args: , ...
}@args:
let let
inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromPypi moduleName; inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromPypi moduleName;
@ -32,43 +33,35 @@ pythonPackages.callPackage (
inherit (pkgs) stdenv; inherit (pkgs) stdenv;
}) selectWheel }) selectWheel
; ;
fileCandidates =
fileCandidates = let let
supportedRegex = ("^.*?(" + builtins.concatStringsSep "|" supportedExtensions + ")"); supportedRegex = ("^.*?(" + builtins.concatStringsSep "|" supportedExtensions + ")");
matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null; matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null;
hasSupportedExtension = fname: builtins.match supportedRegex fname != null; hasSupportedExtension = fname: builtins.match supportedRegex fname != null;
isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname; isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname;
in in
builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file && isCompatibleEgg f.file) files; builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file && isCompatibleEgg f.file) files;
toPath = s: pwd + "/${s}"; toPath = s: pwd + "/${s}";
isSource = source != null; isSource = source != null;
isGit = isSource && source.type == "git"; isGit = isSource && source.type == "git";
isLocal = isSource && source.type == "directory"; isLocal = isSource && source.type == "directory";
localDepPath = toPath source.url; localDepPath = toPath source.url;
pyProject = poetryLib.readTOML (localDepPath + "/pyproject.toml"); pyProject = poetryLib.readTOML (localDepPath + "/pyproject.toml");
buildSystemPkgs = poetryLib.getBuildSystemPkgs { buildSystemPkgs = poetryLib.getBuildSystemPkgs {
inherit pythonPackages pyProject; inherit pythonPackages pyProject;
}; };
fileInfo =
fileInfo = let let
isBdist = f: lib.strings.hasSuffix "whl" f.file; isBdist = f: lib.strings.hasSuffix "whl" f.file;
isSdist = f: ! isBdist f && ! isEgg f; isSdist = f: ! isBdist f && ! isEgg f;
isEgg = f: lib.strings.hasSuffix ".egg" f.file; isEgg = f: lib.strings.hasSuffix ".egg" f.file;
binaryDist = selectWheel fileCandidates;
binaryDist = selectWheel fileCandidates; sourceDist = builtins.filter isSdist fileCandidates;
sourceDist = builtins.filter isSdist fileCandidates; eggs = builtins.filter isEgg fileCandidates;
eggs = builtins.filter isEgg fileCandidates; entries = ( if preferWheel then binaryDist ++ sourceDist else sourceDist ++ binaryDist) ++ eggs;
lockFileEntry = builtins.head entries;
entries = (if preferWheel then binaryDist ++ sourceDist else sourceDist ++ binaryDist) ++ eggs; _isEgg = isEgg lockFileEntry;
in
lockFileEntry = builtins.head entries;
_isEgg = isEgg lockFileEntry;
in
rec { rec {
inherit (lockFileEntry) file hash; inherit (lockFileEntry) file hash;
name = file; name = file;
@ -89,63 +82,65 @@ 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 then "pyproject" else if isGit then "pyproject" else fileInfo.format; format = if isLocal then "pyproject" else if isGit then "pyproject" else fileInfo.format;
in in
buildPythonPackage {
pname = moduleName name;
version = version;
buildPythonPackage { inherit format;
pname = moduleName name;
version = version;
inherit format; doCheck = false; # We never get development deps
doCheck = false; # We never get development deps # Stripping pre-built wheels lead to `ELF load command address/offset not properly aligned`
dontStrip = format == "wheel";
# Stripping pre-built wheels lead to `ELF load command address/offset not properly aligned` nativeBuildInputs = [
dontStrip = format == "wheel"; pythonPackages.poetry2nixFixupHook
]
++ lib.optional (!isSource && (getManyLinuxDeps fileInfo.name).str != null) autoPatchelfHook
++ lib.optional (format == "pyproject") pythonPackages.removePathDependenciesHook
;
nativeBuildInputs = [ buildInputs = (
pythonPackages.poetry2nixFixupHook baseBuildInputs
] ++ lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg
++ lib.optional (!isSource && (getManyLinuxDeps fileInfo.name).str != null) autoPatchelfHook ++ lib.optional isLocal buildSystemPkgs
++ lib.optional (format == "pyproject") pythonPackages.removePathDependenciesHook );
;
buildInputs = ( propagatedBuildInputs =
baseBuildInputs let
++ lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg
++ lib.optional isLocal buildSystemPkgs
);
propagatedBuildInputs = let
compat = isCompatible (poetryLib.getPythonVersion python); compat = isCompatible (poetryLib.getPythonVersion python);
deps = lib.filterAttrs (n: v: v) ( deps = lib.filterAttrs (n: v: v)
lib.mapAttrs ( (
n: v: lib.mapAttrs
let (
constraints = v.python or ""; n: v:
in let
compat constraints constraints = v.python or "";
) dependencies in
); compat constraints
) dependencies
);
depAttrs = lib.attrNames deps; depAttrs = lib.attrNames deps;
in in
builtins.map (n: pythonPackages.${moduleName n}) depAttrs; builtins.map (n: pythonPackages.${moduleName n}) depAttrs;
meta = { meta = {
broken = ! isCompatible (poetryLib.getPythonVersion python) python-versions; broken = ! isCompatible (poetryLib.getPythonVersion python) python-versions;
license = []; license = [ ];
inherit (python.meta) platforms; inherit (python.meta) platforms;
}; };
passthru = { passthru = {
inherit args; inherit args;
}; };
# We need to retrieve kind from the interpreter and the filename of the package # We need to retrieve kind from the interpreter and the filename of the package
# Interpreters should declare what wheel types they're compatible with (python type + ABI) # Interpreters should declare what wheel types they're compatible with (python type + ABI)
# Here we can then choose a file based on that info. # Here we can then choose a file based on that info.
src = if isGit then ( src =
if isGit then (
builtins.fetchGit { builtins.fetchGit {
inherit (source) url; inherit (source) url;
rev = source.reference; rev = source.reference;
@ -155,6 +150,5 @@ pythonPackages.callPackage (
pname = name; pname = name;
inherit (fileInfo) file hash kind; inherit (fileInfo) file hash kind;
}; };
} }
) { }
) {}

View file

@ -1,26 +1,20 @@
# This file has been generated by Niv. # This file has been generated by Niv.
let let
# #
# The fetchers. fetch_<type> fetches specs of type <type>. # The fetchers. fetch_<type> fetches specs of type <type>.
# #
fetch_file = pkgs: spec: fetch_file = pkgs: spec:
if spec.builtin or true then if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; } builtins_fetchurl { inherit (spec) url sha256; }
else else
pkgs.fetchurl { inherit (spec) url sha256; }; pkgs.fetchurl { inherit (spec) url sha256; };
fetch_tarball = pkgs: spec: fetch_tarball = pkgs: spec:
if spec.builtin or true then if spec.builtin or true then
builtins_fetchTarball { inherit (spec) url sha256; } builtins_fetchTarball { inherit (spec) url sha256; }
else else
pkgs.fetchzip { inherit (spec) url sha256; }; pkgs.fetchzip { inherit (spec) url sha256; };
fetch_git = spec: fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; }; builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
fetch_builtin-tarball = spec: fetch_builtin-tarball = spec:
builtins.trace builtins.trace
'' ''
@ -31,7 +25,6 @@ let
$ niv modify <package> -a type=tarball -a builtin=true $ 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: fetch_builtin-url = spec:
builtins.trace builtins.trace
'' ''
@ -51,20 +44,20 @@ let
mkPkgs = sources: mkPkgs = sources:
let let
sourcesNixpkgs = sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {}; import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { };
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.; hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in in
if builtins.hasAttr "nixpkgs" sources if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {} import <nixpkgs> { }
else else
abort abort
'' ''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json. add a package called "nixpkgs" to your sources.json.
''; '';
# The actual fetching function. # The actual fetching function.
fetch = pkgs: name: spec: fetch = pkgs: name: spec:
@ -92,31 +85,32 @@ let
let let
inherit (builtins) lessThan nixVersion fetchTarball; inherit (builtins) lessThan nixVersion fetchTarball;
in in
if lessThan nixVersion "1.12" then if lessThan nixVersion "1.12" then
fetchTarball { inherit url; } fetchTarball { inherit url; }
else else
fetchTarball attrs; fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix # fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, sha256 }@attrs: builtins_fetchurl = { url, sha256 }@attrs:
let let
inherit (builtins) lessThan nixVersion fetchurl; inherit (builtins) lessThan nixVersion fetchurl;
in in
if lessThan nixVersion "1.12" then if lessThan nixVersion "1.12" then
fetchurl { inherit url; } fetchurl { inherit url; }
else else
fetchurl attrs; fetchurl attrs;
# Create the final "sources" from the config # Create the final "sources" from the config
mkSources = config: mkSources = config:
mapAttrs ( mapAttrs
name: spec: (
if builtins.hasAttr "outPath" spec name: spec:
then abort if builtins.hasAttr "outPath" spec
"The values in sources.json should not have an 'outPath' attribute" then abort
else "The values in sources.json should not have an 'outPath' attribute"
spec // { outPath = fetch config.pkgs name spec; } else
) config.sources; spec // { outPath = fetch config.pkgs name spec; }
) config.sources;
# The "config" used by the fetchers # The "config" used by the fetchers
mkConfig = mkConfig =
@ -131,4 +125,4 @@ let
inherit pkgs; inherit pkgs;
}; };
in in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }

File diff suppressed because it is too large Load diff

View file

@ -12,8 +12,7 @@ let
major = builtins.elemAt ver 0; major = builtins.elemAt ver 0;
minor = builtins.elemAt ver 1; minor = builtins.elemAt ver 1;
in in
"cp${major}${minor}"; "cp${major}${minor}";
abiTag = "${pythonTag}m"; abiTag = "${pythonTag}m";
# #
@ -24,13 +23,13 @@ let
entries = splitString "-" str; entries = splitString "-" str;
p = removeSuffix ".whl" (builtins.elemAt entries 4); p = removeSuffix ".whl" (builtins.elemAt entries 4);
in in
{ {
pkgName = builtins.elemAt entries 0; pkgName = builtins.elemAt entries 0;
pkgVer = builtins.elemAt entries 1; pkgVer = builtins.elemAt entries 1;
pyVer = builtins.elemAt entries 2; pyVer = builtins.elemAt entries 2;
abi = builtins.elemAt entries 3; abi = builtins.elemAt entries 3;
platform = p; platform = p;
}; };
# #
# Builds list of acceptable osx wheel files # Builds list of acceptable osx wheel files
@ -42,9 +41,9 @@ let
v = lib.lists.head versions; v = lib.lists.head versions;
vs = lib.lists.tail versions; vs = lib.lists.tail versions;
in in
if (builtins.length versions == 0) if (builtins.length versions == 0)
then [] then [ ]
else (builtins.filter (x: hasInfix v x.file) candidates) ++ (findBestMatches vs candidates); else (builtins.filter (x: hasInfix v x.file) candidates) ++ (findBestMatches vs candidates);
# pyver = "cpXX" # pyver = "cpXX"
# x = "cpXX" | "py2" | "py3" | "py2.py3" # x = "cpXX" | "py2" | "py3" | "py2.py3"
@ -53,7 +52,7 @@ let
normalize = y: ''cp${lib.strings.removePrefix "cp" (lib.strings.removePrefix "py" y)}''; normalize = y: ''cp${lib.strings.removePrefix "cp" (lib.strings.removePrefix "py" y)}'';
isCompat = p: x: lib.strings.hasPrefix (normalize x) p; isCompat = p: x: lib.strings.hasPrefix (normalize x) p;
in in
lib.lists.any (isCompat pyver) (lib.strings.splitString "." x); lib.lists.any (isCompat pyver) (lib.strings.splitString "." x);
# #
# Selects the best matching wheel file from a list of files # Selects the best matching wheel file from a list of files
@ -61,28 +60,23 @@ let
selectWheel = files: selectWheel = files:
let let
filesWithoutSources = (builtins.filter (x: hasSuffix ".whl" x.file) files); filesWithoutSources = (builtins.filter (x: hasSuffix ".whl" x.file) files);
isPyAbiCompatible = pyabi: x: x == "none" || pyabi == x; isPyAbiCompatible = pyabi: x: x == "none" || pyabi == x;
withPython = ver: abi: x: (isPyVersionCompatible ver x.pyVer) && (isPyAbiCompatible abi x.abi); withPython = ver: abi: x: (isPyVersionCompatible ver x.pyVer) && (isPyAbiCompatible abi x.abi);
withPlatform =
withPlatform = if isLinux if isLinux
then ( then (
x: x.platform == "manylinux1_${stdenv.platform.kernelArch}" x: x.platform == "manylinux1_${stdenv.platform.kernelArch}"
|| x.platform == "manylinux2010_${stdenv.platform.kernelArch}" || x.platform == "manylinux2010_${stdenv.platform.kernelArch}"
|| x.platform == "manylinux2014_${stdenv.platform.kernelArch}" || x.platform == "manylinux2014_${stdenv.platform.kernelArch}"
|| x.platform == "any" || x.platform == "any"
) )
else (x: hasInfix "macosx" x.platform || x.platform == "any"); else (x: hasInfix "macosx" x.platform || x.platform == "any");
filterWheel = x: filterWheel = x:
let let
f = toWheelAttrs x.file; f = toWheelAttrs x.file;
in in
(withPython pythonTag abiTag f) && (withPlatform f); (withPython pythonTag abiTag f) && (withPlatform f);
filtered = builtins.filter filterWheel filesWithoutSources; filtered = builtins.filter filterWheel filesWithoutSources;
choose = files: choose = files:
let let
osxMatches = [ "10_12" "10_11" "10_10" "10_9" "any" ]; osxMatches = [ "10_12" "10_11" "10_10" "10_9" "any" ];
@ -90,13 +84,13 @@ let
chooseLinux = x: lib.take 1 (findBestMatches linuxMatches x); chooseLinux = x: lib.take 1 (findBestMatches linuxMatches x);
chooseOSX = x: lib.take 1 (findBestMatches osxMatches x); chooseOSX = x: lib.take 1 (findBestMatches osxMatches x);
in in
if isLinux if isLinux
then chooseLinux files then chooseLinux files
else chooseOSX files; else chooseOSX files;
in in
if (builtins.length filtered == 0) if (builtins.length filtered == 0)
then [] then [ ]
else choose (filtered); else choose (filtered);
in in
{ {
inherit selectWheel toWheelAttrs isPyVersionCompatible; inherit selectWheel toWheelAttrs isPyVersionCompatible;

View file

@ -7,7 +7,6 @@ let
# Strip leading/trailing whitespace from string # Strip leading/trailing whitespace from string
stripStr = s: lib.elemAt (builtins.split "^ *" (lib.elemAt (builtins.split " *$" s) 0)) 2; stripStr = s: lib.elemAt (builtins.split "^ *" (lib.elemAt (builtins.split " *$" s) 0)) 2;
findSubExpressionsFun = acc: c: ( findSubExpressionsFun = acc: c: (
if c == "(" then ( if c == "(" then (
let let
@ -15,23 +14,23 @@ let
isOpen = acc.openP == 0; isOpen = acc.openP == 0;
startPos = if isOpen then posNew else acc.startPos; startPos = if isOpen then posNew else acc.startPos;
in in
acc // { acc // {
inherit startPos; inherit startPos;
exprs = acc.exprs ++ [ (substr acc.exprPos (acc.pos - 1) acc.expr) ]; exprs = acc.exprs ++ [ (substr acc.exprPos (acc.pos - 1) acc.expr) ];
pos = posNew; pos = posNew;
openP = acc.openP + 1; openP = acc.openP + 1;
} }
) else if c == ")" then ( ) else if c == ")" then (
let let
openP = acc.openP - 1; openP = acc.openP - 1;
exprs = findSubExpressions (substr acc.startPos acc.pos acc.expr); exprs = findSubExpressions (substr acc.startPos acc.pos acc.expr);
in in
acc // { acc // {
inherit openP; inherit openP;
pos = acc.pos + 1; pos = acc.pos + 1;
exprs = if openP == 0 then acc.exprs ++ [ exprs ] else acc.exprs; exprs = if openP == 0 then acc.exprs ++ [ exprs ] else acc.exprs;
exprPos = if openP == 0 then acc.pos + 1 else acc.exprPos; exprPos = if openP == 0 then acc.pos + 1 else acc.exprPos;
} }
) else acc // { pos = acc.pos + 1; } ) else acc // { pos = acc.pos + 1; }
); );
@ -39,7 +38,7 @@ let
findSubExpressions = expr: findSubExpressions = expr:
let let
acc = builtins.foldl' findSubExpressionsFun { acc = builtins.foldl' findSubExpressionsFun {
exprs = []; exprs = [ ];
expr = expr; expr = expr;
pos = 0; pos = 0;
openP = 0; openP = 0;
@ -47,18 +46,16 @@ let
startPos = 0; startPos = 0;
} (lib.stringToCharacters expr); } (lib.stringToCharacters expr);
tailExpr = (substr acc.exprPos acc.pos expr); tailExpr = (substr acc.exprPos acc.pos expr);
tailExprs = if tailExpr != "" then [ tailExpr ] else []; tailExprs = if tailExpr != "" then [ tailExpr ] else [ ];
in in
acc.exprs ++ tailExprs; acc.exprs ++ tailExprs;
parseExpressions = exprs: parseExpressions = exprs:
let let
splitCond = ( splitCond = (
s: builtins.map s: builtins.map
(x: stripStr (if builtins.typeOf x == "list" then (builtins.elemAt x 0) else x)) (x: stripStr ( if builtins.typeOf x == "list" then (builtins.elemAt x 0) else x))
(builtins.split " (and|or) " (s + " ")) (builtins.split " (and|or) " (s + " "))
); );
mapfn = expr: ( mapfn = expr: (
if (builtins.match "^ ?$" expr != null) then null # Filter empty if (builtins.match "^ ?$" expr != null) then null # Filter empty
else if (builtins.elem expr [ "and" "or" ]) then { else if (builtins.elem expr [ "and" "or" ]) then {
@ -70,14 +67,13 @@ let
value = expr; value = expr;
} }
); );
parse = expr: builtins.filter (x: x != null) (builtins.map mapfn (splitCond expr)); parse = expr: builtins.filter (x: x != null) (builtins.map mapfn (splitCond expr));
in in
builtins.foldl' ( builtins.foldl'
acc: v: acc ++ ( (
if builtins.typeOf v == "string" then parse v else [ (parseExpressions v) ] acc: v: acc ++ ( if builtins.typeOf v == "string" then parse v else [ (parseExpressions v) ]
) )
) [] exprs; ) [ ] exprs;
# Transform individual expressions to structured expressions # Transform individual expressions to structured expressions
# This function also performs variable substitution, replacing environment markers with their explicit values # This function also performs variable substitution, replacing environment markers with their explicit values
@ -94,9 +90,10 @@ let
else throw "Unsupported platform" else throw "Unsupported platform"
); );
platform_machine = stdenv.platform.kernelArch; platform_machine = stdenv.platform.kernelArch;
platform_python_implementation = let platform_python_implementation =
impl = python.passthru.implementation; let
in impl = python.passthru.implementation;
in
( (
if impl == "cpython" then "CPython" if impl == "cpython" then "CPython"
else if impl == "pypy" then "PyPy" else if impl == "pypy" then "PyPy"
@ -115,34 +112,32 @@ let
implementation_version = python.version; implementation_version = python.version;
extra = ""; extra = "";
}; };
substituteVar = value: if builtins.hasAttr value variables then (builtins.toJSON variables."${value}") else value; substituteVar = value: if builtins.hasAttr value variables then (builtins.toJSON variables."${value}") else value;
processVar = value: builtins.foldl' (acc: v: v acc) value [ processVar = value: builtins.foldl' (acc: v: v acc) value [
stripStr stripStr
substituteVar substituteVar
]; ];
in in
if builtins.typeOf exprs == "set" then ( if builtins.typeOf exprs == "set" then (
if exprs.type == "expr" then ( if exprs.type == "expr" then (
let let
mVal = ''[a-zA-Z0-9\'"_\. ]+''; mVal = ''[a-zA-Z0-9\'"_\. ]+'';
mOp = "in|[!=<>]+"; mOp = "in|[!=<>]+";
e = stripStr exprs.value; e = stripStr exprs.value;
m = builtins.map stripStr (builtins.match ''^(${mVal}) *(${mOp}) *(${mVal})$'' e); m = builtins.map stripStr (builtins.match ''^(${mVal}) *(${mOp}) *(${mVal})$'' e);
in in
{ {
type = "expr"; type = "expr";
value = { value = {
op = builtins.elemAt m 1; op = builtins.elemAt m 1;
values = [ values = [
(processVar (builtins.elemAt m 0)) (processVar (builtins.elemAt m 0))
(processVar (builtins.elemAt m 2)) (processVar (builtins.elemAt m 2))
]; ];
}; };
} }
) else exprs ) else exprs
) else builtins.map transformExpressions exprs; ) else builtins.map transformExpressions exprs;
# Recursively eval all expressions # Recursively eval all expressions
evalExpressions = exprs: evalExpressions = exprs:
@ -165,32 +160,33 @@ let
let let
parts = builtins.splitVersion c; parts = builtins.splitVersion c;
pruned = lib.take ((builtins.length parts) - 1) parts; pruned = lib.take ((builtins.length parts) - 1) parts;
upper = builtins.toString ( upper = builtins.toString
(lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1 (
); (lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1
);
upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned); upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned);
in in
op.">=" v c && op."<" v upperConstraint; op.">=" v c && op."<" v upperConstraint;
"===" = x: y: x == y; "===" = x: y: x == y;
"in" = x: y: "in" = x: y:
let let
values = builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " (unmarshal y)); values = builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " (unmarshal y));
in in
builtins.elem (unmarshal x) values; builtins.elem (unmarshal x) values;
}; };
in in
if builtins.typeOf exprs == "set" then ( if builtins.typeOf exprs == "set" then (
if exprs.type == "expr" then ( if exprs.type == "expr" then (
let let
expr = exprs; expr = exprs;
result = (op."${expr.value.op}") (builtins.elemAt expr.value.values 0) (builtins.elemAt expr.value.values 1); result = (op."${expr.value.op}") (builtins.elemAt expr.value.values 0) (builtins.elemAt expr.value.values 1);
in in
{ {
type = "value"; type = "value";
value = result; value = result;
} }
) else exprs ) else exprs
) else builtins.map evalExpressions exprs; ) else builtins.map evalExpressions exprs;
# Now that we have performed an eval all that's left to do is to concat the graph into a single bool # Now that we have performed an eval all that's left to do is to concat the graph into a single bool
reduceExpressions = exprs: reduceExpressions = exprs:
@ -217,18 +213,18 @@ let
cond = "and"; cond = "and";
} v; } v;
in in
acc // { acc // {
value = cond."${acc.cond}" acc.value ret.value; value = cond."${acc.cond}" acc.value ret.value;
} }
) else throw "Unsupported type" ) else throw "Unsupported type"
); );
in in
( (
builtins.foldl' reduceExpressionsFun { builtins.foldl' reduceExpressionsFun {
value = true; value = true;
cond = "and"; cond = "and";
} exprs } exprs
).value; ).value;
in in
e: builtins.foldl' (acc: v: v acc) e [ e: builtins.foldl' (acc: v: v acc) e [
findSubExpressions findSubExpressions

View file

@ -1,28 +1,28 @@
{ lib, ireplace }: { lib, ireplace }:
let let
inherit (builtins) elemAt match; inherit (builtins) elemAt match;
operators =
operators = let let
matchWildCard = s: match "([^\*])(\.[\*])" s; matchWildCard = s: match "([^\*])(\.[\*])" s;
mkComparison = ret: version: v: builtins.compareVersions version v == ret; mkComparison = ret: version: v: builtins.compareVersions version v == ret;
mkIdxComparison = idx: version: v: mkIdxComparison = idx: version: v:
let let
ver = builtins.splitVersion v; ver = builtins.splitVersion v;
minor = builtins.toString (lib.toInt (elemAt ver idx) + 1); minor = builtins.toString (lib.toInt (elemAt ver idx) + 1);
upper = builtins.concatStringsSep "." (ireplace idx minor ver); upper = builtins.concatStringsSep "." (ireplace idx minor ver);
in in
operators.">=" version v && operators."<" version upper; operators.">=" version v && operators."<" version upper;
dropWildcardPrecision = f: version: constraint: dropWildcardPrecision = f: version: constraint:
let let
m = matchWildCard constraint; m = matchWildCard constraint;
hasWildcard = m != null; hasWildcard = m != null;
c = if hasWildcard then (elemAt m 0) else constraint; c = if hasWildcard then (elemAt m 0) else constraint;
v = v =
if hasWildcard then (builtins.substring 0 (builtins.stringLength c) version) if hasWildcard then (builtins.substring 0 (builtins.stringLength c) version)
else version; else version;
in in
f v c; f v c;
in in
{ {
# Prefix operators # Prefix operators
"==" = dropWildcardPrecision (mkComparison 0); "==" = dropWildcardPrecision (mkComparison 0);
@ -39,24 +39,23 @@ let
# Prune constraint # Prune constraint
parts = builtins.splitVersion c; parts = builtins.splitVersion c;
pruned = lib.take ((builtins.length parts) - 1) parts; pruned = lib.take ((builtins.length parts) - 1) parts;
upper = builtins.toString ( upper = builtins.toString
(lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1 (
); (lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1
);
upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned); upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned);
in in
operators.">=" v c && operators."<" v upperConstraint; operators.">=" v c && operators."<" v upperConstraint;
# Infix operators # Infix operators
"-" = version: v: operators.">=" version v.vl && operators."<=" version v.vu; "-" = version: v: operators.">=" version v.vl && operators."<=" version v.vu;
# Arbitrary equality clause, just run simple comparison # Arbitrary equality clause, just run simple comparison
"===" = v: c: v == c; "===" = v: c: v == c;
# #
}; };
re = { re = {
operators = "([=><!~\^]+)"; operators = "([=><!~\^]+)";
version = "([0-9\.\*x]+)"; version = "([0-9\.\*x]+)";
}; };
parseConstraint = constraint: parseConstraint = constraint:
let let
constraintStr = builtins.replaceStrings [ " " ] [ "" ] constraint; constraintStr = builtins.replaceStrings [ " " ] [ "" ] constraint;
@ -65,26 +64,24 @@ let
# There is also an infix operator to match ranges # There is also an infix operator to match ranges
mIn = match "${re.version} *(-) *${re.version}" constraintStr; mIn = match "${re.version} *(-) *${re.version}" constraintStr;
in in
( (
if mPre != null then { if mPre != null then {
op = elemAt mPre 0; op = elemAt mPre 0;
v = elemAt mPre 1; v = elemAt mPre 1;
} }
# Infix operators are range matches # Infix operators are range matches
else if mIn != null then { else if mIn != null then {
op = elemAt mIn 1; op = elemAt mIn 1;
v = { v = {
vl = (elemAt mIn 0); vl = (elemAt mIn 0);
vu = (elemAt mIn 2); vu = (elemAt mIn 2);
}; };
} }
else throw "Constraint \"${constraintStr}\" could not be parsed" else throw "Constraint \"${constraintStr}\" could not be parsed"
); );
satisfiesSemver = version: constraint: satisfiesSemver = version: constraint:
let let
inherit (parseConstraint constraint) op v; inherit (parseConstraint constraint) op v;
in in if constraint == "*" then true else operators."${op}" version v;
if constraint == "*" then true else operators."${op}" version v;
in in
{ inherit satisfiesSemver; } { inherit satisfiesSemver; }

View file

@ -11,14 +11,15 @@ poetry2nix.mkPoetryApplication {
(import ./poetry-git-overlay.nix { inherit pkgs; }) (import ./poetry-git-overlay.nix { inherit pkgs; })
( (
self: super: { self: super: {
pyramid-deferred-sqla = super.pyramid-deferred-sqla.overridePythonAttrs ( pyramid-deferred-sqla = super.pyramid-deferred-sqla.overridePythonAttrs
old: { (
postPatch = '' old: {
touch LICENSE postPatch = ''
substituteInPlace setup.py --replace 'setup_requires=["pytest-runner"],' "" touch LICENSE
''; substituteInPlace setup.py --replace 'setup_requires=["pytest-runner"],' ""
} '';
); }
);
} }
) )
]; ];

View file

@ -1,14 +1,15 @@
{ pkgs }: { pkgs }:
self: super: { self: super: {
pyramid-deferred-sqla = super.pyramid-deferred-sqla.overridePythonAttrs ( pyramid-deferred-sqla = super.pyramid-deferred-sqla.overridePythonAttrs
_: { (
src = pkgs.fetchgit { _: {
url = "https://github.com/niteoweb/pyramid_deferred_sqla.git"; src = pkgs.fetchgit {
rev = "639b822d16aff7d732a4da2d3752cfdecee00aef"; url = "https://github.com/niteoweb/pyramid_deferred_sqla.git";
sha256 = "0k3azmnqkriy0nz8g2g8fjhfa25i0973pjqhqsfd33ir0prwllz7"; rev = "639b822d16aff7d732a4da2d3752cfdecee00aef";
}; sha256 = "0k3azmnqkriy0nz8g2g8fjhfa25i0973pjqhqsfd33ir0prwllz7";
} };
); }
);
} }

View file

@ -1,53 +1,50 @@
{ pkgs ? import <nixpkgs> {} }: { pkgs ? import <nixpkgs> { } }:
let let
poetry = pkgs.callPackage ../pkgs/poetry { python = pkgs.python3; inherit poetry2nix; }; poetry = pkgs.callPackage ../pkgs/poetry { python = pkgs.python3; inherit poetry2nix; };
poetry2nix = import ./.. { inherit pkgs; inherit poetry; }; poetry2nix = import ./.. { inherit pkgs; inherit poetry; };
pep425 = pkgs.callPackage ../pep425.nix { };
pep425 = pkgs.callPackage ../pep425.nix {};
pep425Python37 = pkgs.callPackage ../pep425.nix { python = pkgs.python37; }; pep425Python37 = pkgs.callPackage ../pep425.nix { python = pkgs.python37; };
pep425OSX = pkgs.callPackage ../pep425.nix { isLinux = false; }; pep425OSX = pkgs.callPackage ../pep425.nix { isLinux = false; };
skipTests = builtins.filter (t: builtins.typeOf t != "list") (builtins.split "," (builtins.getEnv "SKIP_TESTS")); skipTests = builtins.filter (t: builtins.typeOf t != "list") (builtins.split "," (builtins.getEnv "SKIP_TESTS"));
callTest = test: attrs: pkgs.callPackage test ({ inherit poetry2nix; } // attrs); callTest = test: attrs: pkgs.callPackage test ({ inherit poetry2nix; } // attrs);
in in
builtins.removeAttrs builtins.removeAttrs
{ {
trivial = callTest ./trivial {}; trivial = callTest ./trivial { };
override = callTest ./override-support {}; override = callTest ./override-support { };
override-default = callTest ./override-default-support {}; override-default = callTest ./override-default-support { };
top-packages-1 = callTest ./common-pkgs-1 {}; top-packages-1 = callTest ./common-pkgs-1 { };
top-packages-2 = callTest ./common-pkgs-2 {}; top-packages-2 = callTest ./common-pkgs-2 { };
pep425 = pkgs.callPackage ./pep425 { inherit pep425; inherit pep425OSX; inherit pep425Python37; }; pep425 = pkgs.callPackage ./pep425 { inherit pep425; inherit pep425OSX; inherit pep425Python37; };
env = callTest ./env {}; env = callTest ./env { };
git-deps = callTest ./git-deps {}; git-deps = callTest ./git-deps { };
git-deps-pinned = callTest ./git-deps-pinned {}; git-deps-pinned = callTest ./git-deps-pinned { };
cli = poetry2nix; cli = poetry2nix;
path-deps = callTest ./path-deps {}; path-deps = callTest ./path-deps { };
path-deps-level2 = callTest ./path-deps-level2 {}; path-deps-level2 = callTest ./path-deps-level2 { };
operators = callTest ./operators {}; operators = callTest ./operators { };
preferWheel = callTest ./prefer-wheel {}; preferWheel = callTest ./prefer-wheel { };
prefer-wheels = callTest ./prefer-wheels {}; prefer-wheels = callTest ./prefer-wheels { };
closure-size = callTest ./closure-size { closure-size = callTest ./closure-size {
inherit poetry;
inherit (pkgs) postgresql;
};
pyqt5 = callTest ./pyqt5 {};
eggs = callTest ./eggs {};
extras = callTest ./extras {};
source-filter = callTest ./source-filter {};
canonical-module-names = callTest ./canonical-module-names {};
wandb = callTest ./wandb {};
# Test building poetry
inherit poetry; inherit poetry;
poetry-python2 = poetry.override { python = pkgs.python2; }; inherit (pkgs) postgresql;
};
pyqt5 = callTest ./pyqt5 { };
eggs = callTest ./eggs { };
extras = callTest ./extras { };
source-filter = callTest ./source-filter { };
canonical-module-names = callTest ./canonical-module-names { };
wandb = callTest ./wandb { };
# And also test with pypy # Test building poetry
# poetry-pypy = poetry.override { python = pkgs.pypy; }; inherit poetry;
# poetry-pypy3 = poetry.override { python = pkgs.pypy3; }; poetry-python2 = poetry.override { python = pkgs.python2; };
# manylinux requires nixpkgs with https://github.com/NixOS/nixpkgs/pull/75763 # And also test with pypy
# Once this is available in 19.09 and unstable we can re-enable the manylinux test # poetry-pypy = poetry.override { python = pkgs.pypy; };
manylinux = callTest ./manylinux {}; # poetry-pypy3 = poetry.override { python = pkgs.pypy3; };
} skipTests
# manylinux requires nixpkgs with https://github.com/NixOS/nixpkgs/pull/75763
# Once this is available in 19.09 and unstable we can re-enable the manylinux test
manylinux = callTest ./manylinux { };
} skipTests

View file

@ -7,7 +7,7 @@ let
src = lib.cleanSource ./.; src = lib.cleanSource ./.;
}; };
in in
runCommandNoCC "egg-test" {} '' runCommandNoCC "egg-test" { } ''
${drv}/bin/egg-test ${drv}/bin/egg-test
touch $out touch $out
'' ''

View file

@ -6,7 +6,7 @@ let
poetrylock = ./poetry.lock; poetrylock = ./poetry.lock;
}; };
in in
runCommand "env-test" {} '' runCommand "env-test" { } ''
${env}/bin/python -c 'import alembic' ${env}/bin/python -c 'import alembic'
touch $out touch $out
'' ''

View file

@ -1,14 +1,15 @@
{ pkgs }: { pkgs }:
self: super: { self: super: {
alembic = super.alembic.overrideAttrs ( alembic = super.alembic.overrideAttrs
_: { (
src = pkgs.fetchgit { _: {
url = "https://github.com/sqlalchemy/alembic.git"; src = pkgs.fetchgit {
rev = "8d6bb007a4de046c4d338f4b79b40c9fcbf73ab7"; url = "https://github.com/sqlalchemy/alembic.git";
sha256 = "15q4dsn4b1cjf1a4cxymxl2gzdjnv9zlndk98jmpfhssqsr4ky3w"; rev = "8d6bb007a4de046c4d338f4b79b40c9fcbf73ab7";
}; sha256 = "15q4dsn4b1cjf1a4cxymxl2gzdjnv9zlndk98jmpfhssqsr4ky3w";
} };
); }
);
} }

View file

@ -8,7 +8,7 @@ let
}; };
p = pkg.python.withPackages (ps: [ ps.numpy ps.opencv-python ]); p = pkg.python.withPackages (ps: [ ps.numpy ps.opencv-python ]);
in in
runCommand "test" {} '' runCommand "test" { } ''
${p}/bin/python -c "import cv2" ${p}/bin/python -c "import cv2"
touch $out touch $out
'' ''

View file

@ -7,20 +7,22 @@ let
pyproject = ./pyproject.toml; pyproject = ./pyproject.toml;
overrides = [ overrides = [
( (
poetry2nix.defaultPoetryOverrides.overrideOverlay ( poetry2nix.defaultPoetryOverrides.overrideOverlay
self: super: { (
alembic = super.alembic.overrideAttrs ( self: super: {
old: { alembic = super.alembic.overrideAttrs
TESTING_FOOBAR = 42; (
} old: {
); TESTING_FOOBAR = 42;
} }
) );
}
)
) )
]; ];
}; };
in in
runCommand "test" {} '' runCommand "test" { } ''
x=${builtins.toString (p.python.pkgs.alembic.TESTING_FOOBAR)} x=${builtins.toString (p.python.pkgs.alembic.TESTING_FOOBAR)}
[ "$x" = "42" ] || exit 1 [ "$x" = "42" ] || exit 1
mkdir $out mkdir $out

View file

@ -8,16 +8,17 @@ let
overrides = poetry2nix.overrides.withDefaults overrides = poetry2nix.overrides.withDefaults
( (
self: super: { self: super: {
alembic = super.alembic.overrideAttrs ( alembic = super.alembic.overrideAttrs
old: { (
TESTING_FOOBAR = 42; old: {
} TESTING_FOOBAR = 42;
); }
);
} }
); );
}; };
in in
runCommand "test" {} '' runCommand "test" { } ''
x=${builtins.toString (p.python.pkgs.alembic.TESTING_FOOBAR)} x=${builtins.toString (p.python.pkgs.alembic.TESTING_FOOBAR)}
[ "$x" = "42" ] || exit 1 [ "$x" = "42" ] || exit 1
mkdir $out mkdir $out

View file

@ -13,10 +13,10 @@ lib.debug.runTests {
{ file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; }
]; ];
in in
{ {
expr = (pep425.selectWheel cs); expr = (pep425.selectWheel cs);
expected = [ { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } ]; expected = [{ file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; }];
}; };
testOSXSimple = testOSXSimple =
let let
@ -25,10 +25,10 @@ lib.debug.runTests {
{ file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; }
]; ];
in in
{ {
expr = (pep425OSX.selectWheel cs); expr = (pep425OSX.selectWheel cs);
expected = [ { file = "grpcio-1.25.0-cp27-cp27m-macosx_10_10_x86_64.whl"; } ]; expected = [{ file = "grpcio-1.25.0-cp27-cp27m-macosx_10_10_x86_64.whl"; }];
}; };
testLinuxPickPython37 = testLinuxPickPython37 =
let let
@ -41,10 +41,10 @@ lib.debug.runTests {
{ file = "grpcio-1.25.0-cp37-cp37m-manylinux2010_x86_64.whl"; } { file = "grpcio-1.25.0-cp37-cp37m-manylinux2010_x86_64.whl"; }
]; ];
in in
{ {
expr = (pep425Python37.selectWheel cs); expr = (pep425Python37.selectWheel cs);
expected = [ { file = "grpcio-1.25.0-cp37-cp37m-manylinux2010_x86_64.whl"; } ]; expected = [{ file = "grpcio-1.25.0-cp37-cp37m-manylinux2010_x86_64.whl"; }];
}; };
testOSXPreferNewer = testOSXPreferNewer =
let let
@ -53,10 +53,10 @@ lib.debug.runTests {
{ file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; } { file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; }
]; ];
in in
{ {
expr = (pep425OSX.selectWheel cs); expr = (pep425OSX.selectWheel cs);
expected = [ { file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; } ]; expected = [{ file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; }];
}; };
testOSXNoMatch = testOSXNoMatch =
let let
@ -65,10 +65,10 @@ lib.debug.runTests {
{ file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; }
]; ];
in in
{ {
expr = (pep425OSX.selectWheel cs); expr = (pep425OSX.selectWheel cs);
expected = []; expected = [ ];
}; };
testLinuxPreferOlder = testLinuxPreferOlder =
let let
@ -77,10 +77,10 @@ lib.debug.runTests {
{ file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; }
]; ];
in in
{ {
expr = (pep425.selectWheel cs); expr = (pep425.selectWheel cs);
expected = [ { file = "grpcio-1.25.0-cp27-cp27m-manylinux1_x86_64.whl"; } ]; expected = [{ file = "grpcio-1.25.0-cp27-cp27m-manylinux1_x86_64.whl"; }];
}; };
testLinuxNoMatch = testLinuxNoMatch =
let let
@ -89,19 +89,19 @@ lib.debug.runTests {
{ file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; } { file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; }
]; ];
in in
{ {
expr = (pep425.selectWheel cs); expr = (pep425.selectWheel cs);
expected = []; expected = [ ];
}; };
testLinuxEmptyList = { testLinuxEmptyList = {
expr = pep425.selectWheel []; expr = pep425.selectWheel [ ];
expected = []; expected = [ ];
}; };
testOSXEmptyList = { testOSXEmptyList = {
expr = pep425OSX.selectWheel []; expr = pep425OSX.selectWheel [ ];
expected = []; expected = [ ];
}; };
testLinuxCffiWhlFiles = testLinuxCffiWhlFiles =
@ -142,10 +142,10 @@ lib.debug.runTests {
{ file = "cffi-1.13.2.tar.gz"; } { file = "cffi-1.13.2.tar.gz"; }
]; ];
in in
{ {
expr = pep425.selectWheel cs; expr = pep425.selectWheel cs;
expected = [ { file = "cffi-1.13.2-cp27-cp27m-manylinux1_x86_64.whl"; } ]; expected = [{ file = "cffi-1.13.2-cp27-cp27m-manylinux1_x86_64.whl"; }];
}; };
testMsgPack = testMsgPack =
let let
@ -173,10 +173,10 @@ lib.debug.runTests {
{ file = "msgpack-0.6.2.tar.gz"; } { file = "msgpack-0.6.2.tar.gz"; }
]; ];
in in
{ {
expr = pep425Python37.selectWheel cs; expr = pep425Python37.selectWheel cs;
expected = [ { file = "msgpack-0.6.2-cp37-cp37m-manylinux1_x86_64.whl"; } ]; expected = [{ file = "msgpack-0.6.2-cp37-cp37m-manylinux1_x86_64.whl"; }];
}; };
testNonManyLinuxWheels = testNonManyLinuxWheels =
let let
@ -185,10 +185,10 @@ lib.debug.runTests {
{ file = "tensorboard-1.14.0-py3-none-any.whl"; } { file = "tensorboard-1.14.0-py3-none-any.whl"; }
]; ];
in in
{ {
expr = pep425Python37.selectWheel cs; expr = pep425Python37.selectWheel cs;
expected = [ { file = "tensorboard-1.14.0-py3-none-any.whl"; } ]; expected = [{ file = "tensorboard-1.14.0-py3-none-any.whl"; }];
}; };
testPy2Py3Wheels = testPy2Py3Wheels =
let let
@ -196,10 +196,10 @@ lib.debug.runTests {
{ file = "tensorboard-1.14.0-py2.py3-none-any.whl"; } { file = "tensorboard-1.14.0-py2.py3-none-any.whl"; }
]; ];
in in
{ {
expr = pep425Python37.selectWheel cs; expr = pep425Python37.selectWheel cs;
expected = [ { file = "tensorboard-1.14.0-py2.py3-none-any.whl"; } ]; expected = [{ file = "tensorboard-1.14.0-py2.py3-none-any.whl"; }];
}; };
# #
# toWheelAttrs # toWheelAttrs
@ -209,31 +209,31 @@ lib.debug.runTests {
let let
name = "msgpack-0.6.2-cp27-cp27m-manylinux1_i686.whl"; name = "msgpack-0.6.2-cp27-cp27m-manylinux1_i686.whl";
in in
{ {
expr = pep425.toWheelAttrs name; expr = pep425.toWheelAttrs name;
expected = { expected = {
pkgName = "msgpack"; pkgName = "msgpack";
pkgVer = "0.6.2"; pkgVer = "0.6.2";
pyVer = "cp27"; pyVer = "cp27";
abi = "cp27m"; abi = "cp27m";
platform = "manylinux1_i686"; platform = "manylinux1_i686";
};
}; };
};
testToWheelAttrsAny = testToWheelAttrsAny =
let let
name = "tensorboard-1.14.0-py3-none-any.whl"; name = "tensorboard-1.14.0-py3-none-any.whl";
in in
{ {
expr = pep425.toWheelAttrs name; expr = pep425.toWheelAttrs name;
expected = { expected = {
pkgName = "tensorboard"; pkgName = "tensorboard";
pkgVer = "1.14.0"; pkgVer = "1.14.0";
pyVer = "py3"; pyVer = "py3";
abi = "none"; abi = "none";
platform = "any"; platform = "any";
};
}; };
};
# #
# isPyVersionCompatible # isPyVersionCompatible
@ -243,23 +243,23 @@ lib.debug.runTests {
let let
f = pep425.isPyVersionCompatible; f = pep425.isPyVersionCompatible;
in in
{ {
expr = [ expr = [
(f "cp27" "cp27") (f "cp27" "cp27")
(f "cp27" "cp37") (f "cp27" "cp37")
(f "cp27" "py2") (f "cp27" "py2")
(f "cp27" "py3") (f "cp27" "py3")
(f "cp27" "py2.py3") (f "cp27" "py2.py3")
(f "cp37" "py2.py3") (f "cp37" "py2.py3")
]; ];
expected = [ expected = [
true true
false false
true true
false false
true true
]; ];
}; };
} }

View file

@ -15,7 +15,6 @@ let
} }
); );
}; };
url = lib.elemAt drv.passthru.python.pkgs.maturin.src.urls 0; url = lib.elemAt drv.passthru.python.pkgs.maturin.src.urls 0;
in in
assert lib.hasSuffix "whl" url; drv assert lib.hasSuffix "whl" url; drv

View file

@ -1,14 +1,11 @@
{ lib, poetry2nix, python3, runCommand }: { lib, poetry2nix, python3, runCommand }:
let let
app = poetry2nix.mkPoetryApplication { app = poetry2nix.mkPoetryApplication {
projectDir = ./.; projectDir = ./.;
preferWheels = true; preferWheels = true;
}; };
url = lib.elemAt app.passthru.python.pkgs.tensorflow.src.urls 0; url = lib.elemAt app.passthru.python.pkgs.tensorflow.src.urls 0;
in in
assert lib.hasSuffix "whl" url; runCommand "prefer-wheels" {} '' assert lib.hasSuffix "whl" url; runCommand "prefer-wheels" { } ''
touch $out touch $out
'' ''

View file

@ -5,9 +5,10 @@ poetry2nix.mkPoetryApplication {
projectDir = ./.; projectDir = ./.;
# Assert expected ignored files not in sources # Assert expected ignored files not in sources
preConfigure = let preConfigure =
assertNotExists = name: "! test -f ${name} || (echo ${name} exists && false)"; let
in assertNotExists = name: "! test -f ${name} || (echo ${name} exists && false)";
in
'' ''
${assertNotExists "ignored.pyc"} ${assertNotExists "ignored.pyc"}
${assertNotExists "__pycache__"} ${assertNotExists "__pycache__"}

View file

@ -11,13 +11,15 @@ let
in in
{ {
release = let release =
pythonEnv = pkgs.python3.withPackages ( let
ps: [ pythonEnv = pkgs.python3.withPackages
ps.pythonix (
] ps: [
); ps.pythonix
in ]
);
in
pkgs.writeScriptBin "poetry2nix-release" '' pkgs.writeScriptBin "poetry2nix-release" ''
#!${pythonEnv.interpreter} #!${pythonEnv.interpreter}
import subprocess import subprocess
@ -47,18 +49,18 @@ in
exit(p.returncode) exit(p.returncode)
''; '';
flamegraph = let flamegraph =
runtimeDeps = lib.makeBinPath [ let
pkgs.flamegraph runtimeDeps = lib.makeBinPath [
pkgs.python3 pkgs.flamegraph
pkgs.nix pkgs.python3
]; pkgs.nix
];
nixSrc = pkgs.runCommandNoCC "${pkgs.nix.name}-sources" {} '' nixSrc = pkgs.runCommandNoCC "${pkgs.nix.name}-sources" { } ''
mkdir $out mkdir $out
tar -x --strip=1 -f ${pkgs.nix.src} -C $out tar -x --strip=1 -f ${pkgs.nix.src} -C $out
''; '';
in in
pkgs.writeScriptBin "poetry2nix-flamegraph" '' pkgs.writeScriptBin "poetry2nix-flamegraph" ''
#!${pkgs.runtimeShell} #!${pkgs.runtimeShell}
export PATH=${runtimeDeps}:$PATH export PATH=${runtimeDeps}:$PATH