Format with nixpkgs-fmt 0.9

This commit is contained in:
adisbladis 2020-05-19 21:06:02 +01:00
parent 08446e038a
commit db06bdd6e7
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7
24 changed files with 994 additions and 1050 deletions

View file

@ -69,28 +69,28 @@ let
baseOverlay = self: super: baseOverlay = self: super:
let let
getDep = depName: self.${depName}; getDep = depName: self.${depName};
lockPkgs = builtins.listToAttrs lockPkgs = builtins.listToAttrs (
( builtins.map
builtins.map (
( pkgMeta: rec {
pkgMeta: rec { name = moduleName pkgMeta.name;
name = moduleName pkgMeta.name; value = self.mkPoetryDep (
value = self.mkPoetryDep pkgMeta // {
( inherit pwd preferWheels;
pkgMeta // { source = pkgMeta.source or null;
inherit pwd preferWheels; files = lockFiles.${name};
source = pkgMeta.source or null; pythonPackages = self;
files = lockFiles.${name}; sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name};
pythonPackages = self; }
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
( (
[ [
( (
@ -145,22 +145,23 @@ let
, editablePackageSources ? { } , editablePackageSources ? { }
}: }:
let let
py = mkPoetryPackages py = mkPoetryPackages (
( {
{ inherit pyproject poetrylock overrides python pwd preferWheels;
inherit pyproject poetrylock overrides python pwd preferWheels; }
} );
);
editablePackages = lib.mapAttrsToList editablePackages = lib.mapAttrsToList
(name: src: (name: src:
# Creates a "fake" python module that just points to the editable source directory # Creates a "fake" python module that just points to the editable source directory
# See https://docs.python.org/3.8/library/site.html for info on such .pth files # See https://docs.python.org/3.8/library/site.html for info on such .pth files
py.python.pkgs.toPythonModule py.python.pkgs.toPythonModule (pkgs.runCommandNoCC "${name}-editable"
(pkgs.runCommandNoCC "${name}-editable" { } '' { } ''
mkdir -p "$out/${py.python.sitePackages}" mkdir -p "$out/${py.python.sitePackages}"
echo "${toString src}" > "$out/${py.python.sitePackages}/${name}.pth" echo "${toString src}" > "$out/${py.python.sitePackages}/${name}.pth"
'') ''
) editablePackageSources; )
)
editablePackageSources;
in in
py.python.withPackages (_: py.poetryPackages ++ editablePackages); py.python.withPackages (_: py.poetryPackages ++ editablePackages);
@ -214,54 +215,54 @@ let
pkg = py.pkgs."${dep}"; pkg = py.pkgs."${dep}";
constraints = deps.${dep}.python or ""; constraints = deps.${dep}.python or "";
isCompat = compat constraints; isCompat = compat constraints;
in if isCompat then pkg else null in
) depAttrs; if isCompat then pkg else null
)
depAttrs;
getInputs = attr: attrs.${attr} or [ ]; getInputs = attr: attrs.${attr} or [ ];
mkInput = attr: extraInputs: getInputs attr ++ extraInputs; mkInput = attr: extraInputs: getInputs attr ++ extraInputs;
buildSystemPkgs = poetryLib.getBuildSystemPkgs { buildSystemPkgs = poetryLib.getBuildSystemPkgs {
inherit pyProject; inherit pyProject;
pythonPackages = py.pkgs; pythonPackages = py.pkgs;
}; };
app = py.pkgs.buildPythonPackage app = py.pkgs.buildPythonPackage (
( passedAttrs // {
passedAttrs // { pname = moduleName pyProject.tool.poetry.name;
pname = moduleName pyProject.tool.poetry.name; version = pyProject.tool.poetry.version;
version = pyProject.tool.poetry.version;
inherit src; inherit src;
format = "pyproject"; format = "pyproject";
# Like buildPythonApplication, but without the toPythonModule part # Like buildPythonApplication, but without the toPythonModule part
# Meaning this ends up looking like an application but it also # Meaning this ends up looking like an application but it also
# provides python modules # provides python modules
namePrefix = ""; namePrefix = "";
buildInputs = mkInput "buildInputs" buildSystemPkgs; buildInputs = mkInput "buildInputs" buildSystemPkgs;
propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ py.pkgs.setuptools ]); propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ py.pkgs.setuptools ]);
nativeBuildInputs = mkInput "nativeBuildInputs" [ pkgs.yj py.pkgs.removePathDependenciesHook ]; nativeBuildInputs = mkInput "nativeBuildInputs" [ pkgs.yj py.pkgs.removePathDependenciesHook ];
checkInputs = mkInput "checkInputs" (getDeps "dev-dependencies"); checkInputs = mkInput "checkInputs" (getDeps "dev-dependencies");
passthru = { passthru = {
python = py; python = py;
dependencyEnv = dependencyEnv = (
(lib.makeOverridable lib.makeOverridable ({ app, ... }@attrs:
({ app, ... }@attrs: let
let args = builtins.removeAttrs attrs [ "app" ] // {
args = builtins.removeAttrs attrs [ "app" ] // { extraLibs = [ app ];
extraLibs = [ app ]; };
}; in
in py.buildEnv.override args)) { inherit app; };
py.buildEnv.override args)) { inherit app; }; };
};
meta = meta // { meta = meta // {
inherit (pyProject.tool.poetry) description homepage; inherit (pyProject.tool.poetry) description homepage;
inherit (py.meta) platforms; inherit (py.meta) platforms;
license = getLicenseBySpdxId (pyProject.tool.poetry.license or "unknown"); license = getLicenseBySpdxId (pyProject.tool.poetry.license or "unknown");
}; };
} }
); );
in in
app; app;

View file

@ -9,26 +9,24 @@
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

@ -14,36 +14,39 @@ in
removePathDependenciesHook = callPackage removePathDependenciesHook = callPackage
( (
{}: {}:
makeSetupHook { makeSetupHook
name = "remove-path-dependencies.sh"; {
deps = [ ]; name = "remove-path-dependencies.sh";
substitutions = { deps = [ ];
inherit pythonInterpreter; substitutions = {
yj = "${yj}/bin/yj"; inherit pythonInterpreter;
pyprojectPatchScript = "${./pyproject-without-path.py}"; yj = "${yj}/bin/yj";
}; 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"; {
deps = [ pip wheel ]; name = "pip-build-hook.sh";
substitutions = { deps = [ pip wheel ];
inherit pythonInterpreter pythonSitePackages; substitutions = {
}; inherit pythonInterpreter pythonSitePackages;
} ./pip-build-hook.sh };
} ./pip-build-hook.sh
) { }; ) { };
poetry2nixFixupHook = callPackage poetry2nixFixupHook = callPackage
( (
{}: {}:
makeSetupHook { makeSetupHook
name = "fixup-hook.sh"; {
deps = [ ]; name = "fixup-hook.sh";
} ./fixup-hook.sh deps = [ ];
} ./fixup-hook.sh
) { }; ) { };
} }

118
lib.nix
View file

@ -20,7 +20,7 @@ let
minor = l: lib.elemAt l 1; minor = l: lib.elemAt l 1;
joinVersion = v: lib.concatStringsSep "." v; joinVersion = v: lib.concatStringsSep "." v;
in in
joinVersion ( if major pyVer == major ver && minor pyVer == minor ver then ver else pyVer); 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:
@ -45,28 +45,27 @@ let
state = operators."${operator}" acc.state (satisfiesSemver version v); state = operators."${operator}" acc.state (satisfiesSemver version v);
}; };
initial = { operator = "&&"; state = true; }; initial = { operator = "&&"; state = true; };
in if expr == "" then true else (builtins.foldl' combine initial tokens).state; 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 (
builtins.readFile pkgs.runCommand "from-toml"
( {
pkgs.runCommand "from-toml" inherit toml;
{ allowSubstitutes = false;
inherit toml; preferLocalBuild = true;
allowSubstitutes = false; }
preferLocalBuild = true; ''
} ${pkgs.remarshal}/bin/remarshal \
'' -if toml \
${pkgs.remarshal}/bin/remarshal \ -i <(echo "$toml") \
-if toml \ -of json \
-i <(echo "$toml") \ -o $out
-of json \ ''
-o $out
''
)
) )
)
); );
readTOML = path: fromTOML (builtins.readFile path); readTOML = path: fromTOML (builtins.readFile path);
@ -88,11 +87,10 @@ let
# file: filename including extension # file: filename including extension
# hash: SRI hash # hash: SRI hash
# kind: Language implementation and version tag # kind: Language implementation and version tag
predictURLFromPypi = lib.makeOverridable predictURLFromPypi = lib.makeOverridable (
( { pname, file, hash, kind }:
{ pname, file, hash, kind }: "https://files.pythonhosted.org/packages/${kind}/${lib.toLower (builtins.substring 0 1 file)}/${pname}/${file}"
"https://files.pythonhosted.org/packages/${kind}/${lib.toLower (builtins.substring 0 1 file)}/${pname}/${file}" );
);
# Fetch the wheels from the PyPI index. # Fetch the wheels from the PyPI index.
@ -102,36 +100,35 @@ let
# file: filename including extension # file: filename including extension
# hash: SRI hash # hash: SRI hash
# kind: Language implementation and version tag # kind: Language implementation and version tag
fetchWheelFromPypi = lib.makeOverridable fetchWheelFromPypi = lib.makeOverridable (
( { pname, file, hash, kind, curlOpts ? "" }:
{ pname, file, hash, kind, curlOpts ? "" }: let
let version = builtins.elemAt (builtins.split "-" file) 2;
version = builtins.elemAt (builtins.split "-" file) 2; in
in (pkgs.stdenvNoCC.mkDerivation {
(pkgs.stdenvNoCC.mkDerivation { name = file;
name = file; nativeBuildInputs = [
nativeBuildInputs = [ pkgs.curl
pkgs.curl pkgs.jq
pkgs.jq ];
]; isWheel = true;
isWheel = true; system = "builtin";
system = "builtin";
preferLocalBuild = true; preferLocalBuild = true;
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
"NIX_CURL_FLAGS" "NIX_CURL_FLAGS"
]; ];
predictedURL = predictURLFromPypi { inherit pname file hash kind; }; predictedURL = predictURLFromPypi { inherit pname file hash kind; };
inherit pname file version curlOpts; inherit pname file version curlOpts;
builder = ./fetch-wheel.sh; builder = ./fetch-wheel.sh;
outputHashMode = "flat"; outputHashMode = "flat";
outputHashAlgo = "sha256"; outputHashAlgo = "sha256";
outputHash = hash; outputHash = hash;
}) })
); );
# 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
@ -143,16 +140,15 @@ 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 }: if lib.strings.hasSuffix "whl" file then fetchWheelFromPypi { inherit pname file hash kind; }
if lib.strings.hasSuffix "whl" file then fetchWheelFromPypi { inherit pname file hash kind; } else
else pkgs.fetchurl {
pkgs.fetchurl { url = predictURLFromPypi { inherit pname file hash kind; };
url = predictURLFromPypi { inherit pname file hash kind; }; inherit hash;
inherit hash; }
} );
);
getBuildSystemPkgs = getBuildSystemPkgs =
{ pythonPackages { pythonPackages
, pyProject , pyProject

View file

@ -58,7 +58,7 @@ pythonPackages.callPackage
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; entries = (if preferWheel then binaryDist ++ sourceDist else sourceDist ++ binaryDist) ++ eggs;
lockFileEntry = builtins.head entries; lockFileEntry = builtins.head entries;
_isEgg = isEgg lockFileEntry; _isEgg = isEgg lockFileEntry;
in in
@ -111,7 +111,8 @@ pythonPackages.callPackage
propagatedBuildInputs = propagatedBuildInputs =
let 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 lib.mapAttrs
( (
@ -120,7 +121,8 @@ pythonPackages.callPackage
constraints = v.python or ""; constraints = v.python or "";
in in
compat constraints compat constraints
) dependencies )
dependencies
); );
depAttrs = lib.attrNames deps; depAttrs = lib.attrNames deps;
in in

View file

@ -110,7 +110,8 @@ let
"The values in sources.json should not have an 'outPath' attribute" "The values in sources.json should not have an 'outPath' attribute"
else else
spec // { outPath = fetch config.pkgs name spec; } spec // { outPath = fetch config.pkgs name spec; }
) config.sources; )
config.sources;
# The "config" used by the fetchers # The "config" used by the fetchers
mkConfig = mkConfig =

File diff suppressed because it is too large Load diff

View file

@ -37,14 +37,17 @@ let
# Make a tree out of expression groups (parens) # Make a tree out of expression groups (parens)
findSubExpressions = expr: findSubExpressions = expr:
let let
acc = builtins.foldl' findSubExpressionsFun { acc = builtins.foldl'
exprs = [ ]; findSubExpressionsFun
expr = expr; {
pos = 0; exprs = [ ];
openP = 0; expr = expr;
exprPos = 0; pos = 0;
startPos = 0; openP = 0;
} (lib.stringToCharacters expr); exprPos = 0;
startPos = 0;
}
(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
@ -53,7 +56,7 @@ let
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: (
@ -71,8 +74,9 @@ let
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
@ -159,10 +163,9 @@ 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;
@ -207,10 +210,13 @@ let
) else throw "Unsupported type" ) else throw "Unsupported type"
) else if builtins.typeOf v == "list" then ( ) else if builtins.typeOf v == "list" then (
let let
ret = builtins.foldl' reduceExpressionsFun { ret = builtins.foldl'
value = true; reduceExpressionsFun
cond = "and"; {
} v; value = true;
cond = "and";
}
v;
in in
acc // { acc // {
value = cond."${acc.cond}" acc.value ret.value; value = cond."${acc.cond}" acc.value ret.value;
@ -219,10 +225,13 @@ let
); );
in in
( (
builtins.foldl' reduceExpressionsFun { builtins.foldl'
value = true; reduceExpressionsFun
cond = "and"; {
} exprs value = true;
cond = "and";
}
exprs
).value; ).value;
in in
e: builtins.foldl' (acc: v: v acc) e [ e: builtins.foldl' (acc: v: v acc) e [

View file

@ -39,10 +39,9 @@ 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;
@ -69,7 +68,7 @@ let
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 = {
@ -82,6 +81,7 @@ let
satisfiesSemver = version: constraint: satisfiesSemver = version: constraint:
let let
inherit (parseConstraint constraint) op v; inherit (parseConstraint constraint) op v;
in if constraint == "*" then true else operators."${op}" version v; in
if constraint == "*" then true else operators."${op}" version v;
in in
{ inherit satisfiesSemver; } { inherit satisfiesSemver; }

View file

@ -11,15 +11,14 @@ 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: {
old: { postPatch = ''
postPatch = '' touch LICENSE
touch LICENSE substituteInPlace setup.py --replace 'setup_requires=["pytest-runner"],' ""
substituteInPlace setup.py --replace 'setup_requires=["pytest-runner"],' "" '';
''; }
} );
);
} }
) )
]; ];

View file

@ -1,15 +1,14 @@
{ 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 {
src = pkgs.fetchgit { url = "https://github.com/niteoweb/pyramid_deferred_sqla.git";
url = "https://github.com/niteoweb/pyramid_deferred_sqla.git"; rev = "639b822d16aff7d732a4da2d3752cfdecee00aef";
rev = "639b822d16aff7d732a4da2d3752cfdecee00aef"; sha256 = "0k3azmnqkriy0nz8g2g8fjhfa25i0973pjqhqsfd33ir0prwllz7";
sha256 = "0k3azmnqkriy0nz8g2g8fjhfa25i0973pjqhqsfd33ir0prwllz7"; };
}; }
} );
);
} }

View file

@ -1,7 +1,7 @@
{ 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; };
@ -15,7 +15,7 @@ builtins.removeAttrs
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 { };
@ -49,4 +49,5 @@ builtins.removeAttrs
# manylinux requires nixpkgs with https://github.com/NixOS/nixpkgs/pull/75763 # 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 # Once this is available in 19.09 and unstable we can re-enable the manylinux test
manylinux = callTest ./manylinux { }; manylinux = callTest ./manylinux { };
} skipTests }
skipTests

View file

@ -9,16 +9,16 @@ let
# Test support for overriding the app passed to the environment # Test support for overriding the app passed to the environment
overridden = ( overridden = (
app.overrideAttrs app.overrideAttrs (old: {
(old: { name = "${old.pname}-overridden-${old.version}";
name = "${old.pname}-overridden-${old.version}"; })
})
); );
depEnv = app.dependencyEnv.override { depEnv = app.dependencyEnv.override {
app = overridden; app = overridden;
}; };
in in
runCommand "app-env-test" { } '' runCommand "app-env-test"
{ } ''
${depEnv}/bin/gunicorn --bind=unix:socket trivial:app & ${depEnv}/bin/gunicorn --bind=unix:socket trivial:app &
sleep 1 sleep 1
${curl}/bin/curl --unix-socket socket localhost ${curl}/bin/curl --unix-socket socket localhost

View file

@ -13,7 +13,8 @@ let
}; };
}; };
in in
runCommand "env-test" { } '' runCommand "env-test"
{ } ''
cp -r --no-preserve=mode ${./src} src cp -r --no-preserve=mode ${./src} src
echo 'print("Changed")' > src/trivial/__main__.py echo 'print("Changed")' > src/trivial/__main__.py
if [[ $(${env}/bin/python -m trivial) != "Changed" ]]; then if [[ $(${env}/bin/python -m trivial) != "Changed" ]]; then

View file

@ -7,7 +7,8 @@ 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,8 @@ 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

@ -6,7 +6,6 @@ poetry2nix.mkPoetryApplication {
poetrylock = ./poetry.lock; poetrylock = ./poetry.lock;
src = lib.cleanSource ./.; src = lib.cleanSource ./.;
overrides = poetry2nix.overrides.withDefaults overrides = poetry2nix.overrides.withDefaults (import ./poetry-git-overlay.nix { inherit pkgs; });
(import ./poetry-git-overlay.nix { inherit pkgs; });
} }

View file

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

View file

@ -8,7 +8,8 @@ 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,22 +7,21 @@ let
pyproject = ./pyproject.toml; pyproject = ./pyproject.toml;
overrides = [ overrides = [
( (
poetry2nix.defaultPoetryOverrides.overrideOverlay poetry2nix.defaultPoetryOverrides.overrideOverlay (
( 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

@ -5,20 +5,19 @@ let
src = ./.; src = ./.;
poetrylock = ./poetry.lock; poetrylock = ./poetry.lock;
pyproject = ./pyproject.toml; pyproject = ./pyproject.toml;
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

@ -17,4 +17,4 @@ let
}; };
isWheelAttr = drv.passthru.python.pkgs.maturin.src.isWheel or false; isWheelAttr = drv.passthru.python.pkgs.maturin.src.isWheel or false;
in in
assert isWheelAttr; drv assert isWheelAttr; drv

View file

@ -6,4 +6,4 @@ let
}; };
isWheelAttr = py.python.pkgs.tensorflow.src.isWheel or false; isWheelAttr = py.python.pkgs.tensorflow.src.isWheel or false;
in in
assert isWheelAttr; (py.python.withPackages (_: py.poetryPackages)).override (args: { ignoreCollisions = true; }) assert isWheelAttr; (py.python.withPackages (_: py.poetryPackages)).override (args: { ignoreCollisions = true; })

View file

@ -13,12 +13,11 @@ in
release = release =
let let
pythonEnv = pkgs.python3.withPackages pythonEnv = pkgs.python3.withPackages (
( ps: [
ps: [ ps.pythonix
ps.pythonix ]
] );
);
in in
pkgs.writeScriptBin "poetry2nix-release" '' pkgs.writeScriptBin "poetry2nix-release" ''
#!${pythonEnv.interpreter} #!${pythonEnv.interpreter}
@ -56,7 +55,8 @@ in
pkgs.python3 pkgs.python3
pkgs.nix 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
''; '';