From 4ebbfdacd1b14a6713c634c2af6e3f880e416fd3 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Wed, 29 Apr 2020 14:12:59 +0100 Subject: [PATCH] nixpkgs-fmt broke it's format yet again --- cli.nix | 6 +- default.nix | 279 ++-- flake.nix | 18 +- hooks/default.nix | 25 +- lib.nix | 122 +- mk-poetry-dep.nix | 150 +- nix/sources.nix | 64 +- overrides.nix | 1331 +++++++++-------- pep425.nix | 62 +- pep508.nix | 146 +- semver.nix | 85 +- tests/canonical-module-names/default.nix | 17 +- .../poetry-git-overlay.nix | 19 +- tests/default.nix | 79 +- tests/eggs/default.nix | 2 +- tests/env/default.nix | 2 +- tests/git-deps-pinned/poetry-git-overlay.nix | 19 +- tests/manylinux/default.nix | 2 +- tests/override-default-support/default.nix | 22 +- tests/override-support/default.nix | 13 +- tests/pep425/default.nix | 166 +- tests/prefer-wheel/default.nix | 1 - tests/prefer-wheels/default.nix | 9 +- tests/source-filter/default.nix | 7 +- tools/default.nix | 40 +- 25 files changed, 1367 insertions(+), 1319 deletions(-) diff --git a/cli.nix b/cli.nix index fbcee74..b96316e 100644 --- a/cli.nix +++ b/cli.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} +{ pkgs ? import { } , lib ? pkgs.lib , version }: @@ -33,8 +33,8 @@ pkgs.stdenv.mkDerivation { mv poetry2nix $out/bin wrapProgram $out/bin/poetry2nix --prefix PATH ":" ${lib.makeBinPath [ - pkgs.nix-prefetch-git - ]} + pkgs.nix-prefetch-git + ]} runHook postInstall ''; diff --git a/default.nix b/default.nix index 15e2981..df52bd0 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} +{ pkgs ? import { } , lib ? pkgs.lib , poetry ? null , poetryLib ? import ./lib.nix { inherit lib pkgs; } @@ -11,12 +11,10 @@ let /* The default list of poetry2nix override overlays */ defaultPoetryOverrides = (import ./overrides.nix { inherit pkgs lib; }); - mkEvalPep508 = import ./pep508.nix { inherit lib poetryLib; stdenv = pkgs.stdenv; }; - getFunctorFn = fn: if builtins.typeOf fn == "set" then fn.__functor else fn; # Map SPDX identifiers to license names @@ -36,78 +34,80 @@ let , pwd ? projectDir , preferWheels ? false }@attrs: - let - poetryPkg = poetry.override { inherit python; }; - - pyProject = readTOML pyproject; - poetryLock = readTOML poetrylock; - lockFiles = let + let + poetryPkg = poetry.override { inherit python; }; + pyProject = readTOML pyproject; + poetryLock = readTOML poetrylock; + lockFiles = + let 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 = [ - "overrides" - "poetrylock" - "projectDir" - "pwd" - "preferWheels" - ]; - passedAttrs = builtins.removeAttrs attrs specialAttrs; - - evalPep508 = mkEvalPep508 python; - - # Filter packages by their PEP508 markers & pyproject interpreter version - partitions = let + # Filter packages by their PEP508 markers & pyproject interpreter version + partitions = + let supportsPythonVersion = pkgMeta: if pkgMeta ? marker then (evalPep508 pkgMeta.marker) else true; in - lib.partition supportsPythonVersion poetryLock.package; + lib.partition supportsPythonVersion poetryLock.package; + compatible = partitions.right; + incompatible = partitions.wrong; - compatible = partitions.right; - incompatible = partitions.wrong; - - # Create an overriden version of pythonPackages - # - # We need to avoid mixing multiple versions of pythonPackages in the same - # closure as python can only ever have one version of a dependency - baseOverlay = self: super: - let - getDep = depName: self.${depName}; - - lockPkgs = builtins.listToAttrs ( - builtins.map ( - pkgMeta: rec { - name = moduleName pkgMeta.name; - value = self.mkPoetryDep ( - pkgMeta // { - inherit pwd preferWheels; - source = pkgMeta.source or null; - files = lockFiles.${name}; - pythonPackages = self; - sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name}; - } - ); - } - ) compatible + # Create an overriden version of pythonPackages + # + # We need to avoid mixing multiple versions of pythonPackages in the same + # closure as python can only ever have one version of a dependency + baseOverlay = self: super: + let + getDep = depName: self.${depName}; + lockPkgs = builtins.listToAttrs + ( + builtins.map + ( + pkgMeta: rec { + name = moduleName pkgMeta.name; + value = self.mkPoetryDep + ( + pkgMeta // { + inherit pwd preferWheels; + source = pkgMeta.source or null; + files = lockFiles.${name}; + pythonPackages = self; + sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name}; + } + ); + } + ) compatible ); - in - lockPkgs; - overlays = builtins.map getFunctorFn ( + in + lockPkgs; + overlays = builtins.map getFunctorFn + ( [ ( self: super: let - hooks = self.callPackage ./hooks {}; + hooks = self.callPackage ./hooks { }; in - { - mkPoetryDep = self.callPackage ./mk-poetry-dep.nix { - inherit pkgs lib python poetryLib; - }; - poetry = poetryPkg; - # The canonical name is setuptools-scm - setuptools-scm = super.setuptools_scm; + { + mkPoetryDep = self.callPackage ./mk-poetry-dep.nix { + inherit pkgs lib python poetryLib; + }; + poetry = poetryPkg; + # The canonical name is 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 (self: super: builtins.listToAttrs (builtins.map (x: { name = moduleName x.name; value = null; }) incompatible)) @@ -116,17 +116,15 @@ let ] ++ # User provided overrides overrides ); - - packageOverrides = lib.foldr lib.composeExtensions (self: super: {}) overlays; - - py = python.override { inherit packageOverrides; self = py; }; - in - { - python = py; - poetryPackages = map (pkg: py.pkgs.${moduleName pkg.name}) compatible; - poetryLock = poetryLock; - inherit pyProject; - }; + packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) overlays; + py = python.override { inherit packageOverrides; self = py; }; + in + { + python = py; + poetryPackages = map (pkg: py.pkgs.${moduleName pkg.name}) compatible; + poetryLock = poetryLock; + inherit pyProject; + }; /* 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 , preferWheels ? false }: - let - py = mkPoetryPackages ( + let + py = mkPoetryPackages + ( { inherit pyproject poetrylock overrides python pwd preferWheels; } ); - in - py.python.withPackages (_: py.poetryPackages); + in + py.python.withPackages (_: py.poetryPackages); /* Creates a Python application from pyproject.toml and poetry.lock */ mkPoetryApplication = @@ -158,81 +157,79 @@ let , pyproject ? projectDir + "/pyproject.toml" , poetrylock ? projectDir + "/poetry.lock" , overrides ? [ defaultPoetryOverrides ] - , meta ? {} + , meta ? { } , python ? pkgs.python3 , pwd ? projectDir , preferWheels ? false , ... }@attrs: - let - poetryPython = mkPoetryPackages { - inherit pyproject poetrylock overrides python pwd preferWheels; - }; - py = poetryPython.python; + let + poetryPython = mkPoetryPackages { + inherit pyproject poetrylock overrides python pwd preferWheels; + }; + py = poetryPython.python; - inherit (poetryPython) pyProject; + inherit (poetryPython) pyProject; + specialAttrs = [ + "overrides" + "poetrylock" + "projectDir" + "pwd" + "pyproject" + "preferWheels" + ]; + passedAttrs = builtins.removeAttrs attrs specialAttrs; - specialAttrs = [ - "overrides" - "poetrylock" - "projectDir" - "pwd" - "pyproject" - "preferWheels" - ]; - passedAttrs = builtins.removeAttrs attrs specialAttrs; + # Get dependencies and filter out depending on interpreter version + 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 [ ]; + 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 - 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; + inherit src; - getInputs = attr: attrs.${attr} or []; - mkInput = attr: extraInputs: getInputs attr ++ extraInputs; + format = "pyproject"; - buildSystemPkgs = poetryLib.getBuildSystemPkgs { - inherit pyProject; - pythonPackages = py.pkgs; - }; - in - py.pkgs.buildPythonApplication ( - passedAttrs // { - pname = moduleName pyProject.tool.poetry.name; - version = pyProject.tool.poetry.version; + 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"); - 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 */ cli = import ./cli.nix { inherit pkgs lib version; }; @@ -254,7 +251,7 @@ in defaultSet = defaultPoetryOverrides self super; customSet = fn self super; in - defaultSet // customSet; + defaultSet // customSet; }; /* diff --git a/flake.nix b/flake.nix index 79ed957..4f7c04c 100644 --- a/flake.nix +++ b/flake.nix @@ -9,24 +9,26 @@ systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ]; forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); # Memoize nixpkgs for different platforms for efficiency. - nixpkgsFor = forAllSystems ( - system: + nixpkgsFor = forAllSystems + ( + system: import nixpkgs { inherit system; overlays = [ self.overlay ]; } - ); + ); in - { + { - overlay = import ./overlay.nix; + overlay = import ./overlay.nix; - # TODO: I feel like `packages` is the wrong place for the poetry2nix attr - packages = forAllSystems ( + # TODO: I feel like `packages` is the wrong place for the poetry2nix attr + packages = forAllSystems + ( system: { inherit (nixpkgsFor.${system}) poetry poetry2nix; } ); - }; + }; } diff --git a/hooks/default.nix b/hooks/default.nix index 16a39a7..ae5867b 100644 --- a/hooks/default.nix +++ b/hooks/default.nix @@ -11,21 +11,23 @@ let in { - removePathDependenciesHook = callPackage ( - {}: + removePathDependenciesHook = callPackage + ( + {}: makeSetupHook { name = "remove-path-dependencies.sh"; - deps = []; + deps = [ ]; substitutions = { inherit pythonInterpreter; yj = "${yj}/bin/yj"; pyprojectPatchScript = "${./pyproject-without-path.py}"; }; } ./remove-path-dependencies.sh - ) {}; + ) { }; - pipBuildHook = callPackage ( - { pip, wheel }: + pipBuildHook = callPackage + ( + { pip, wheel }: makeSetupHook { name = "pip-build-hook.sh"; deps = [ pip wheel ]; @@ -33,14 +35,15 @@ in inherit pythonInterpreter pythonSitePackages; }; } ./pip-build-hook.sh - ) {}; + ) { }; - poetry2nixFixupHook = callPackage ( - {}: + poetry2nixFixupHook = callPackage + ( + {}: makeSetupHook { name = "fixup-hook.sh"; - deps = []; + deps = [ ]; } ./fixup-hook.sh - ) {}; + ) { }; } diff --git a/lib.nix b/lib.nix index 790eca3..01a15e0 100644 --- a/lib.nix +++ b/lib.nix @@ -12,13 +12,15 @@ let moduleName = name: lib.toLower (lib.replaceStrings [ "_" "." ] [ "-" "-" ] name); # Get a full semver pythonVersion from a python derivation - getPythonVersion = python: let - pyVer = lib.splitVersion python.pythonVersion ++ [ "0" ]; - ver = lib.splitVersion python.version; - major = l: lib.elemAt l 0; - minor = l: lib.elemAt l 1; - joinVersion = v: lib.concatStringsSep "." v; - in joinVersion (if major pyVer == major ver && minor pyVer == minor ver then ver else pyVer); + getPythonVersion = python: + let + pyVer = lib.splitVersion python.pythonVersion ++ [ "0" ]; + ver = lib.splitVersion python.version; + major = l: lib.elemAt l 0; + minor = l: lib.elemAt l 1; + 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 isCompatible = version: @@ -30,41 +32,41 @@ let }; splitRe = "(" + (builtins.concatStringsSep "|" (builtins.map (x: lib.replaceStrings [ "|" ] [ "\\|" ] x) (lib.attrNames operators))) + ")"; in - expr: + expr: + let + tokens = builtins.filter (x: x != "") (builtins.split splitRe expr); + combine = acc: v: let - tokens = builtins.filter (x: x != "") (builtins.split splitRe expr); - combine = acc: v: - 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; }; + isOperator = builtins.typeOf v == "list"; + operator = if isOperator then (builtins.elemAt v 0) else acc.operator; 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 ( - toml: builtins.fromJSON ( - builtins.readFile ( - pkgs.runCommand "from-toml" - { - inherit toml; - allowSubstitutes = false; - preferLocalBuild = true; - } - '' - ${pkgs.remarshal}/bin/remarshal \ - -if toml \ - -i <(echo "$toml") \ - -of json \ - -o $out - '' + toml: builtins.fromJSON + ( + builtins.readFile + ( + pkgs.runCommand "from-toml" + { + inherit toml; + allowSubstitutes = false; + preferLocalBuild = true; + } + '' + ${pkgs.remarshal}/bin/remarshal \ + -if toml \ + -i <(echo "$toml") \ + -of json \ + -o $out + '' + ) ) - ) ); readTOML = path: fromTOML (builtins.readFile path); @@ -75,10 +77,10 @@ let let ml = pkgs.pythonManylinuxPackages; in - 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 "manylinux2014" f then { pkg = [ ml.manylinux2014 ]; str = "2014"; } - else { pkg = []; str = null; }; + 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 "manylinux2014" f then { pkg = [ ml.manylinux2014 ]; str = "2014"; } + else { pkg = [ ]; str = null; }; # Fetch the artifacts from the PyPI index. Since we get all # info we need from the lock file we don't use nixpkgs' fetchPyPi @@ -90,25 +92,25 @@ let # file: filename including extension # hash: SRI hash # kind: Language implementation and version tag https://www.python.org/dev/peps/pep-0427/#file-name-convention - fetchFromPypi = lib.makeOverridable ( - { pname, file, hash, kind }: + fetchFromPypi = lib.makeOverridable + ( + { pname, file, hash, kind }: pkgs.fetchurl { url = "https://files.pythonhosted.org/packages/${kind}/${lib.toLower (builtins.substring 0 1 file)}/${pname}/${file}"; inherit hash; } - ); - + ); getBuildSystemPkgs = { pythonPackages , pyProject }: - let - buildSystem = lib.attrByPath [ "build-system" "build-backend" ] "" pyProject; - drvAttr = moduleName (builtins.elemAt (builtins.split "\\.|:" buildSystem) 0); - in - if buildSystem == "" then [] else ( - [ pythonPackages.${drvAttr} or (throw "unsupported build system ${buildSystem}") ] - ); + let + buildSystem = lib.attrByPath [ "build-system" "build-backend" ] "" pyProject; + drvAttr = moduleName (builtins.elemAt (builtins.split "\\.|:" buildSystem) 0); + in + if buildSystem == "" then [ ] else ( + [ pythonPackages.${drvAttr} or (throw "unsupported build system ${buildSystem}") ] + ); # Find gitignore files recursively in parent directory stopping with .git findGitIgnores = path: @@ -117,9 +119,9 @@ let gitIgnore = path + "/.gitignore"; isGitRoot = builtins.pathExists (path + "/.git"); hasGitIgnore = builtins.pathExists gitIgnore; - gitIgnores = if hasGitIgnore then [ gitIgnore ] else []; + gitIgnores = if hasGitIgnore then [ gitIgnore ] else [ ]; 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: @@ -136,13 +138,13 @@ let || (type == "regular" && ! lib.strings.hasSuffix ".pyc" name) ; in - lib.cleanSourceWith { - filter = lib.cleanSourceFilter; - src = lib.cleanSourceWith { - filter = pkgs.nix-gitignore.gitignoreFilterPure pycacheFilter gitIgnores src; - inherit src; - }; + lib.cleanSourceWith { + filter = lib.cleanSourceFilter; + src = lib.cleanSourceWith { + filter = pkgs.nix-gitignore.gitignoreFilterPure pycacheFilter gitIgnores src; + inherit src; }; + }; in { inherit diff --git a/mk-poetry-dep.nix b/mk-poetry-dep.nix index 6953d4e..2467dad 100644 --- a/mk-poetry-dep.nix +++ b/mk-poetry-dep.nix @@ -10,7 +10,7 @@ , version , files , source -, dependencies ? {} +, dependencies ? { } , pythonPackages , python-versions , pwd @@ -20,10 +20,11 @@ , ... }: -pythonPackages.callPackage ( - { preferWheel ? preferWheels - , ... - }@args: +pythonPackages.callPackage + ( + { preferWheel ? preferWheels + , ... + }@args: let inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromPypi moduleName; @@ -32,43 +33,35 @@ pythonPackages.callPackage ( inherit (pkgs) stdenv; }) selectWheel ; - - fileCandidates = let - supportedRegex = ("^.*?(" + builtins.concatStringsSep "|" supportedExtensions + ")"); - matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null; - hasSupportedExtension = fname: builtins.match supportedRegex fname != null; - isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname; - in + fileCandidates = + let + supportedRegex = ("^.*?(" + builtins.concatStringsSep "|" supportedExtensions + ")"); + matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null; + hasSupportedExtension = fname: builtins.match supportedRegex fname != null; + isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname; + in builtins.filter (f: matchesVersion f.file && hasSupportedExtension f.file && isCompatibleEgg f.file) files; - toPath = s: pwd + "/${s}"; - isSource = source != null; isGit = isSource && source.type == "git"; isLocal = isSource && source.type == "directory"; - localDepPath = toPath source.url; pyProject = poetryLib.readTOML (localDepPath + "/pyproject.toml"); - buildSystemPkgs = poetryLib.getBuildSystemPkgs { inherit pythonPackages pyProject; }; - - fileInfo = let - isBdist = f: lib.strings.hasSuffix "whl" f.file; - isSdist = f: ! isBdist f && ! isEgg f; - isEgg = f: lib.strings.hasSuffix ".egg" f.file; - - binaryDist = selectWheel fileCandidates; - sourceDist = builtins.filter isSdist fileCandidates; - eggs = builtins.filter isEgg fileCandidates; - - entries = (if preferWheel then binaryDist ++ sourceDist else sourceDist ++ binaryDist) ++ eggs; - - lockFileEntry = builtins.head entries; - - _isEgg = isEgg lockFileEntry; - in + fileInfo = + let + isBdist = f: lib.strings.hasSuffix "whl" f.file; + isSdist = f: ! isBdist f && ! isEgg f; + isEgg = f: lib.strings.hasSuffix ".egg" f.file; + binaryDist = selectWheel fileCandidates; + sourceDist = builtins.filter isSdist fileCandidates; + eggs = builtins.filter isEgg fileCandidates; + entries = ( if preferWheel then binaryDist ++ sourceDist else sourceDist ++ binaryDist) ++ eggs; + lockFileEntry = builtins.head entries; + _isEgg = isEgg lockFileEntry; + in rec { inherit (lockFileEntry) file hash; name = file; @@ -89,63 +82,65 @@ pythonPackages.callPackage ( "toml" # Toml is an extra for 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; in + buildPythonPackage { + pname = moduleName name; + version = version; - buildPythonPackage { - pname = moduleName name; - version = version; + inherit format; - 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` - dontStrip = format == "wheel"; + nativeBuildInputs = [ + pythonPackages.poetry2nixFixupHook + ] + ++ lib.optional (!isSource && (getManyLinuxDeps fileInfo.name).str != null) autoPatchelfHook + ++ lib.optional (format == "pyproject") pythonPackages.removePathDependenciesHook + ; - nativeBuildInputs = [ - pythonPackages.poetry2nixFixupHook - ] - ++ lib.optional (!isSource && (getManyLinuxDeps fileInfo.name).str != null) autoPatchelfHook - ++ lib.optional (format == "pyproject") pythonPackages.removePathDependenciesHook - ; + buildInputs = ( + baseBuildInputs + ++ lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg + ++ lib.optional isLocal buildSystemPkgs + ); - buildInputs = ( - baseBuildInputs - ++ lib.optional (!isSource) (getManyLinuxDeps fileInfo.name).pkg - ++ lib.optional isLocal buildSystemPkgs - ); - - propagatedBuildInputs = let + propagatedBuildInputs = + let compat = isCompatible (poetryLib.getPythonVersion python); - deps = lib.filterAttrs (n: v: v) ( - lib.mapAttrs ( - n: v: - let - constraints = v.python or ""; - in - compat constraints - ) dependencies - ); + deps = lib.filterAttrs (n: v: v) + ( + lib.mapAttrs + ( + n: v: + let + constraints = v.python or ""; + in + compat constraints + ) dependencies + ); depAttrs = lib.attrNames deps; in - builtins.map (n: pythonPackages.${moduleName n}) depAttrs; + builtins.map (n: pythonPackages.${moduleName n}) depAttrs; - meta = { - broken = ! isCompatible (poetryLib.getPythonVersion python) python-versions; - license = []; - inherit (python.meta) platforms; - }; + meta = { + broken = ! isCompatible (poetryLib.getPythonVersion python) python-versions; + license = [ ]; + inherit (python.meta) platforms; + }; - passthru = { - inherit args; - }; + passthru = { + inherit args; + }; - # 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) - # Here we can then choose a file based on that info. - src = if isGit then ( + # 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) + # Here we can then choose a file based on that info. + src = + if isGit then ( builtins.fetchGit { inherit (source) url; rev = source.reference; @@ -155,6 +150,5 @@ pythonPackages.callPackage ( pname = name; inherit (fileInfo) file hash kind; }; - } - -) {} + } + ) { } diff --git a/nix/sources.nix b/nix/sources.nix index 8a725cb..7605916 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -1,26 +1,20 @@ # This file has been generated by Niv. - let - # # The fetchers. fetch_ fetches specs of type . # - fetch_file = pkgs: spec: if spec.builtin or true then builtins_fetchurl { inherit (spec) url sha256; } else pkgs.fetchurl { inherit (spec) url sha256; }; - fetch_tarball = pkgs: spec: if spec.builtin or true then builtins_fetchTarball { inherit (spec) url sha256; } else pkgs.fetchzip { inherit (spec) url sha256; }; - fetch_git = spec: builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; }; - fetch_builtin-tarball = spec: builtins.trace '' @@ -31,7 +25,6 @@ let $ niv modify -a type=tarball -a builtin=true '' builtins_fetchTarball { inherit (spec) url sha256; }; - fetch_builtin-url = spec: builtins.trace '' @@ -51,20 +44,20 @@ let mkPkgs = sources: let 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; hasThisAsNixpkgsPath = == ./.; in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; + if builtins.hasAttr "nixpkgs" sources + then sourcesNixpkgs + else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + import { } + else + abort + '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; # The actual fetching function. fetch = pkgs: name: spec: @@ -92,31 +85,32 @@ let let inherit (builtins) lessThan nixVersion fetchTarball; in - if lessThan nixVersion "1.12" then - fetchTarball { inherit url; } - else - fetchTarball attrs; + if lessThan nixVersion "1.12" then + fetchTarball { inherit url; } + else + fetchTarball attrs; # fetchurl version that is compatible between all the versions of Nix builtins_fetchurl = { url, sha256 }@attrs: let inherit (builtins) lessThan nixVersion fetchurl; in - if lessThan nixVersion "1.12" then - fetchurl { inherit url; } - else - fetchurl attrs; + if lessThan nixVersion "1.12" then + fetchurl { inherit url; } + else + fetchurl attrs; # Create the final "sources" from the config mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = fetch config.pkgs name spec; } - ) config.sources; + mapAttrs + ( + name: spec: + if builtins.hasAttr "outPath" spec + then abort + "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = fetch config.pkgs name spec; } + ) config.sources; # The "config" used by the fetchers mkConfig = @@ -131,4 +125,4 @@ let inherit pkgs; }; in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } +mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/overrides.nix b/overrides.nix index 561f2dd..d8d35e3 100644 --- a/overrides.nix +++ b/overrides.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} +{ pkgs ? import { } , lib ? pkgs.lib , stdenv ? pkgs.stdenv }: @@ -6,223 +6,248 @@ self: super: { - astroid = super.astroid.overridePythonAttrs ( - old: rec { - buildInputs = old.buildInputs ++ [ self.pytest-runner ]; - doCheck = false; - } - ); + astroid = super.astroid.overridePythonAttrs + ( + old: rec { + buildInputs = old.buildInputs ++ [ self.pytest-runner ]; + doCheck = false; + } + ); - av = super.av.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ - pkgs.pkgconfig - ]; - buildInputs = old.buildInputs ++ [ pkgs.ffmpeg_4 ]; - } - ); + av = super.av.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ + pkgs.pkgconfig + ]; + buildInputs = old.buildInputs ++ [ pkgs.ffmpeg_4 ]; + } + ); - bcrypt = super.bcrypt.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ pkgs.libffi ]; - } - ); + bcrypt = super.bcrypt.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ pkgs.libffi ]; + } + ); cffi = # cffi is bundled with pypy if self.python.implementation == "pypy" then null else ( - super.cffi.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ pkgs.libffi ]; - } - ) + super.cffi.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ pkgs.libffi ]; + } + ) ); - cftime = super.cftime.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - self.cython - ]; - } - ); + cftime = super.cftime.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ + self.cython + ]; + } + ); - configparser = super.configparser.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - self.toml - ]; + configparser = super.configparser.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ + self.toml + ]; - postPatch = '' - substituteInPlace setup.py --replace 'setuptools.setup()' 'setuptools.setup(version="${old.version}")' - ''; - } - ); + postPatch = '' + substituteInPlace setup.py --replace 'setuptools.setup()' 'setuptools.setup(version="${old.version}")' + ''; + } + ); - cryptography = super.cryptography.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ pkgs.openssl ]; - } - ); + cryptography = super.cryptography.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ pkgs.openssl ]; + } + ); django = ( - super.django.overridePythonAttrs ( + super.django.overridePythonAttrs + ( + old: { + propagatedNativeBuildInputs = (old.propagatedNativeBuildInputs or [ ]) + ++ [ pkgs.gettext ]; + } + ) + ); + + django-bakery = super.django-bakery.overridePythonAttrs + ( old: { - propagatedNativeBuildInputs = (old.propagatedNativeBuildInputs or []) - ++ [ pkgs.gettext ]; + configurePhase = '' + if ! test -e LICENSE; then + touch LICENSE + fi + '' + (old.configurePhase or ""); } - ) - ); + ); - django-bakery = super.django-bakery.overridePythonAttrs ( - old: { - configurePhase = '' - if ! test -e LICENSE; then - touch LICENSE - fi - '' + (old.configurePhase or ""); - } - ); + dlib = super.dlib.overridePythonAttrs + ( + old: { + # Parallel building enabled + inherit (pkgs.python.pkgs.dlib) patches; - dlib = super.dlib.overridePythonAttrs ( - old: { - # Parallel building enabled - inherit (pkgs.python.pkgs.dlib) patches; + enableParallelBuilding = true; + dontUseCmakeConfigure = true; - enableParallelBuilding = true; - dontUseCmakeConfigure = true; - - nativeBuildInputs = old.nativeBuildInputs ++ pkgs.dlib.nativeBuildInputs; - buildInputs = old.buildInputs ++ pkgs.dlib.buildInputs; - } - ); + nativeBuildInputs = old.nativeBuildInputs ++ pkgs.dlib.nativeBuildInputs; + buildInputs = old.buildInputs ++ pkgs.dlib.buildInputs; + } + ); # Environment markers are not always included (depending on how a dep was defined) enum34 = if self.pythonAtLeast "3.4" then null else super.enum34; - faker = super.faker.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ self.pytest-runner ]; - doCheck = false; - } - ); + faker = super.faker.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ self.pytest-runner ]; + doCheck = false; + } + ); - fancycompleter = super.fancycompleter.overridePythonAttrs ( - old: { - postPatch = '' - substituteInPlace setup.py \ - --replace 'setup_requires="setupmeta"' 'setup_requires=[]' \ - --replace 'versioning="devcommit"' 'version="${old.version}"' - ''; - } - ); + fancycompleter = super.fancycompleter.overridePythonAttrs + ( + old: { + postPatch = '' + substituteInPlace setup.py \ + --replace 'setup_requires="setupmeta"' 'setup_requires=[]' \ + --replace 'versioning="devcommit"' 'version="${old.version}"' + ''; + } + ); - fastparquet = super.fastparquet.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ self.pytest-runner ]; - } - ); + fastparquet = super.fastparquet.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ self.pytest-runner ]; + } + ); - grandalf = super.grandalf.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ self.pytest-runner ]; - doCheck = false; - } - ); + grandalf = super.grandalf.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ self.pytest-runner ]; + doCheck = false; + } + ); - h5py = super.h5py.overridePythonAttrs ( - old: rec { - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; - buildInputs = old.buildInputs ++ [ pkgs.hdf5 self.pkgconfig self.cython ]; - configure_flags = "--hdf5=${pkgs.hdf5}"; - postConfigure = '' - ${self.python.executable} setup.py configure ${configure_flags} - ''; - } - ); + h5py = super.h5py.overridePythonAttrs + ( + old: rec { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; + buildInputs = old.buildInputs ++ [ pkgs.hdf5 self.pkgconfig self.cython ]; + configure_flags = "--hdf5=${pkgs.hdf5}"; + postConfigure = '' + ${self.python.executable} setup.py configure ${configure_flags} + ''; + } + ); - horovod = super.horovod.overridePythonAttrs ( - old: { - propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.openmpi ]; - } - ); + horovod = super.horovod.overridePythonAttrs + ( + old: { + propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.openmpi ]; + } + ); # importlib-metadata has an incomplete dependency specification - importlib-metadata = super.importlib-metadata.overridePythonAttrs ( - old: { - propagatedBuildInputs = old.propagatedBuildInputs ++ lib.optional self.python.isPy2 self.pathlib2; - } - ); + importlib-metadata = super.importlib-metadata.overridePythonAttrs + ( + old: { + propagatedBuildInputs = old.propagatedBuildInputs ++ lib.optional self.python.isPy2 self.pathlib2; + } + ); - jupyter = super.jupyter.overridePythonAttrs ( - old: rec { - # jupyter is a meta-package. Everything relevant comes from the - # dependencies. It does however have a jupyter.py file that conflicts - # with jupyter-core so this meta solves this conflict. - meta.priority = 100; - } - ); + jupyter = super.jupyter.overridePythonAttrs + ( + old: rec { + # jupyter is a meta-package. Everything relevant comes from the + # dependencies. It does however have a jupyter.py file that conflicts + # with jupyter-core so this meta solves this conflict. + meta.priority = 100; + } + ); - kiwisolver = super.kiwisolver.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - # cppy is at the time of writing not in nixpkgs - (self.cppy or null) - ]; - } - ); + kiwisolver = super.kiwisolver.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ + # cppy is at the time of writing not in nixpkgs + (self.cppy or null) + ]; + } + ); - lap = super.lap.overridePythonAttrs ( - old: { - propagatedBuildInputs = old.propagatedBuildInputs ++ [ - self.numpy - ]; - } - ); + lap = super.lap.overridePythonAttrs + ( + old: { + propagatedBuildInputs = old.propagatedBuildInputs ++ [ + self.numpy + ]; + } + ); - llvmlite = super.llvmlite.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.llvm ]; + llvmlite = super.llvmlite.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.llvm ]; - # Disable static linking - # https://github.com/numba/llvmlite/issues/93 - postPatch = '' - substituteInPlace ffi/Makefile.linux --replace "-static-libstdc++" "" + # Disable static linking + # https://github.com/numba/llvmlite/issues/93 + postPatch = '' + substituteInPlace ffi/Makefile.linux --replace "-static-libstdc++" "" - substituteInPlace llvmlite/tests/test_binding.py --replace "test_linux" "nope" - ''; + substituteInPlace llvmlite/tests/test_binding.py --replace "test_linux" "nope" + ''; - # Set directory containing llvm-config binary - preConfigure = '' - export LLVM_CONFIG=${pkgs.llvm}/bin/llvm-config - ''; + # Set directory containing llvm-config binary + preConfigure = '' + export LLVM_CONFIG=${pkgs.llvm}/bin/llvm-config + ''; - __impureHostDeps = pkgs.stdenv.lib.optionals pkgs.stdenv.isDarwin [ "/usr/lib/libm.dylib" ]; + __impureHostDeps = pkgs.stdenv.lib.optionals pkgs.stdenv.isDarwin [ "/usr/lib/libm.dylib" ]; - passthru = old.passthru // { llvm = pkgs.llvm; }; - } - ); + passthru = old.passthru // { llvm = pkgs.llvm; }; + } + ); - lockfile = super.lockfile.overridePythonAttrs ( - old: { - propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pbr ]; - } - ); + lockfile = super.lockfile.overridePythonAttrs + ( + old: { + propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pbr ]; + } + ); - lxml = super.lxml.overridePythonAttrs ( - old: { - nativeBuildInputs = with pkgs; old.nativeBuildInputs ++ [ pkgconfig libxml2.dev libxslt.dev ]; - buildInputs = with pkgs; old.buildInputs ++ [ libxml2 libxslt ]; - } - ); + lxml = super.lxml.overridePythonAttrs + ( + old: { + nativeBuildInputs = with pkgs; old.nativeBuildInputs ++ [ pkgconfig libxml2.dev libxslt.dev ]; + buildInputs = with pkgs; old.buildInputs ++ [ libxml2 libxslt ]; + } + ); - markupsafe = super.markupsafe.overridePythonAttrs ( - old: { - src = old.src.override { pname = builtins.replaceStrings [ "markupsafe" ] [ "MarkupSafe" ] old.pname; }; - } - ); + markupsafe = super.markupsafe.overridePythonAttrs + ( + old: { + src = old.src.override { pname = builtins.replaceStrings [ "markupsafe" ] [ "MarkupSafe" ] old.pname; }; + } + ); - matplotlib = super.matplotlib.overridePythonAttrs ( - old: + matplotlib = super.matplotlib.overridePythonAttrs + ( + old: let enableGhostscript = old.passthru.enableGhostscript or false; enableGtk3 = old.passthru.enableTk or false; @@ -231,76 +256,79 @@ self: super: inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa; in - { - NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${pkgs.libcxx}/include/c++/v1"; + { + NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${pkgs.libcxx}/include/c++/v1"; - XDG_RUNTIME_DIR = "/tmp"; + XDG_RUNTIME_DIR = "/tmp"; - buildInputs = old.buildInputs + buildInputs = old.buildInputs ++ lib.optional enableGhostscript pkgs.ghostscript ++ lib.optional stdenv.isDarwin [ Cocoa ]; - nativeBuildInputs = old.nativeBuildInputs ++ [ - pkgs.pkgconfig - ]; + nativeBuildInputs = old.nativeBuildInputs ++ [ + pkgs.pkgconfig + ]; - propagatedBuildInputs = old.propagatedBuildInputs ++ [ - pkgs.libpng - pkgs.freetype - ] + propagatedBuildInputs = old.propagatedBuildInputs ++ [ + pkgs.libpng + pkgs.freetype + ] ++ stdenv.lib.optionals enableGtk3 [ pkgs.cairo self.pycairo pkgs.gtk3 pkgs.gobject-introspection self.pygobject3 ] ++ stdenv.lib.optionals enableTk [ pkgs.tcl pkgs.tk self.tkinter pkgs.libX11 ] ++ stdenv.lib.optionals enableQt [ self.pyqt5 ] - ; + ; - inherit (super.matplotlib) patches; - } - ); + inherit (super.matplotlib) patches; + } + ); # Calls Cargo at build time for source builds and is really tricky to package maturin = super.maturin.override { preferWheel = true; }; - mccabe = super.mccabe.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ self.pytest-runner ]; - doCheck = false; - } - ); + mccabe = super.mccabe.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ self.pytest-runner ]; + doCheck = false; + } + ); - netcdf4 = super.netcdf4.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - self.cython - ]; + netcdf4 = super.netcdf4.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ + self.cython + ]; - propagatedBuildInputs = old.propagatedBuildInputs ++ [ - pkgs.zlib - pkgs.netcdf - pkgs.hdf5 - pkgs.curl - pkgs.libjpeg - ]; + propagatedBuildInputs = old.propagatedBuildInputs ++ [ + pkgs.zlib + pkgs.netcdf + pkgs.hdf5 + pkgs.curl + pkgs.libjpeg + ]; - # Variables used to configure the build process - USE_NCCONFIG = "0"; - HDF5_DIR = lib.getDev pkgs.hdf5; - NETCDF4_DIR = pkgs.netcdf; - CURL_DIR = pkgs.curl.dev; - JPEG_DIR = pkgs.libjpeg.dev; - } - ); + # Variables used to configure the build process + USE_NCCONFIG = "0"; + HDF5_DIR = lib.getDev pkgs.hdf5; + NETCDF4_DIR = pkgs.netcdf; + CURL_DIR = pkgs.curl.dev; + JPEG_DIR = pkgs.libjpeg.dev; + } + ); - numpy = super.numpy.overridePythonAttrs ( - old: + numpy = super.numpy.overridePythonAttrs + ( + old: let blas = old.passthru.args.blas or pkgs.openblasCompat; blasImplementation = lib.nameFromURL blas.name "-"; cfg = pkgs.writeTextFile { name = "site.cfg"; text = ( - lib.generators.toINI {} { + lib.generators.toINI { } { ${blasImplementation} = { include_dirs = "${blas}/include"; library_dirs = "${blas}/lib"; @@ -312,458 +340,497 @@ self: super: ); }; in - { - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ]; - buildInputs = old.buildInputs ++ [ blas self.cython ]; - enableParallelBuilding = true; - preBuild = '' - ln -s ${cfg} site.cfg - ''; - passthru = old.passthru // { - blas = blas; - inherit blasImplementation cfg; - }; - } - ); + { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ]; + buildInputs = old.buildInputs ++ [ blas self.cython ]; + enableParallelBuilding = true; + preBuild = '' + ln -s ${cfg} site.cfg + ''; + passthru = old.passthru // { + blas = blas; + inherit blasImplementation cfg; + }; + } + ); - openexr = super.openexr.overridePythonAttrs ( - old: rec { - buildInputs = old.buildInputs ++ [ pkgs.openexr pkgs.ilmbase ]; - NIX_CFLAGS_COMPILE = [ "-I${pkgs.openexr.dev}/include/OpenEXR" "-I${pkgs.ilmbase.dev}/include/OpenEXR" ]; - } - ); + openexr = super.openexr.overridePythonAttrs + ( + old: rec { + buildInputs = old.buildInputs ++ [ pkgs.openexr pkgs.ilmbase ]; + NIX_CFLAGS_COMPILE = [ "-I${pkgs.openexr.dev}/include/OpenEXR" "-I${pkgs.ilmbase.dev}/include/OpenEXR" ]; + } + ); - peewee = super.peewee.overridePythonAttrs ( - old: + peewee = super.peewee.overridePythonAttrs + ( + old: let withPostgres = old.passthru.withPostgres or false; withMysql = old.passthru.withMysql or false; in - { - buildInputs = old.buildInputs ++ [ self.cython pkgs.sqlite ]; - propagatedBuildInputs = old.propagatedBuildInputs + { + buildInputs = old.buildInputs ++ [ self.cython pkgs.sqlite ]; + propagatedBuildInputs = old.propagatedBuildInputs ++ lib.optional withPostgres self.psycopg2 ++ lib.optional withMysql self.mysql-connector; + } + ); + + pillow = super.pillow.overridePythonAttrs + ( + old: { + nativeBuildInputs = [ pkgs.pkgconfig ] ++ old.nativeBuildInputs; + buildInputs = with pkgs; [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ] ++ old.buildInputs; + } + ); + + psycopg2 = super.psycopg2.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ]; + } + ); + + psycopg2-binary = super.psycopg2-binary.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ]; + } + ); + + pyarrow = + if lib.versionAtLeast super.pyarrow.version "0.16.0" then super.pyarrow.overridePythonAttrs + ( + old: + let + parseMinor = drv: lib.concatStringsSep "." (lib.take 2 (lib.splitVersion drv.version)); + _arrow-cpp = pkgs.arrow-cpp.override { inherit (self) python; }; + ARROW_HOME = _arrow-cpp; + arrowCppVersion = parseMinor pkgs.arrow-cpp; + pyArrowVersion = parseMinor super.pyarrow; + errorMessage = "arrow-cpp version (${arrowCppVersion}) mismatches pyarrow version (${pyArrowVersion})"; + in + if arrowCppVersion != pyArrowVersion then throw errorMessage else { + + nativeBuildInputs = old.nativeBuildInputs ++ [ + self.cython + pkgs.pkgconfig + pkgs.cmake + ]; + + preBuild = '' + export PYARROW_PARALLEL=$NIX_BUILD_CORES + ''; + + PARQUET_HOME = _arrow-cpp; + inherit ARROW_HOME; + + buildInputs = old.buildInputs ++ [ + pkgs.arrow-cpp + ]; + + PYARROW_BUILD_TYPE = "release"; + PYARROW_WITH_PARQUET = true; + PYARROW_CMAKE_OPTIONS = [ + "-DCMAKE_INSTALL_RPATH=${ARROW_HOME}/lib" + + # This doesn't use setup hook to call cmake so we need to workaround #54606 + # ourselves + "-DCMAKE_POLICY_DEFAULT_CMP0025=NEW" + ]; + + dontUseCmakeConfigure = true; } - ); + ) else super.pyarrow.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ + self.cython + ]; + } + ); - pillow = super.pillow.overridePythonAttrs ( - old: { - nativeBuildInputs = [ pkgs.pkgconfig ] ++ old.nativeBuildInputs; - buildInputs = with pkgs; [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ] ++ old.buildInputs; - } - ); + pycairo = + ( + drv: ( + drv.overridePythonAttrs + ( + _: { + format = "other"; + } + ) + ).overridePythonAttrs + ( + old: { - psycopg2 = super.psycopg2.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ]; - } - ); + nativeBuildInputs = old.nativeBuildInputs ++ [ + pkgs.meson + pkgs.ninja + pkgs.pkgconfig + ]; - psycopg2-binary = super.psycopg2-binary.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ]; - } - ); + propagatedBuildInputs = old.propagatedBuildInputs ++ [ + pkgs.cairo + pkgs.xlibsWrapper + ]; - pyarrow = if lib.versionAtLeast super.pyarrow.version "0.16.0" then super.pyarrow.overridePythonAttrs ( - old: - let - parseMinor = drv: lib.concatStringsSep "." (lib.take 2 (lib.splitVersion drv.version)); - _arrow-cpp = pkgs.arrow-cpp.override { inherit (self) python; }; - ARROW_HOME = _arrow-cpp; + mesonFlags = [ "-Dpython=${ if self.isPy3k then "python3" else "python"}" ]; + } + ) + ) super.pycairo; - arrowCppVersion = parseMinor pkgs.arrow-cpp; - pyArrowVersion = parseMinor super.pyarrow; - errorMessage = "arrow-cpp version (${arrowCppVersion}) mismatches pyarrow version (${pyArrowVersion})"; - in if arrowCppVersion != pyArrowVersion then throw errorMessage else { + pycocotools = super.pycocotools.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ + self.cython + self.numpy + ]; + } + ); + + pygobject = super.pygobject.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; + buildInputs = old.buildInputs ++ [ pkgs.glib pkgs.gobject-introspection ]; + } + ); + + pylint = super.pylint.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ self.pytest-runner ]; + doCheck = false; + } + ); + + pyopenssl = super.pyopenssl.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ pkgs.openssl ]; + } + ); + + pyqt5 = + let + drv = super.pyqt5; + withConnectivity = drv.passthru.args.withConnectivity or false; + withMultimedia = drv.passthru.args.withMultimedia or false; + withWebKit = drv.passthru.args.withWebKit or false; + withWebSockets = drv.passthru.args.withWebSockets or false; + in + super.pyqt5.overridePythonAttrs + ( + old: { + format = "other"; + + nativeBuildInputs = old.nativeBuildInputs ++ [ + pkgs.pkgconfig + pkgs.qt5.qmake + pkgs.xorg.lndir + pkgs.qt5.qtbase + pkgs.qt5.qtsvg + pkgs.qt5.qtdeclarative + pkgs.qt5.qtwebchannel + # self.pyqt5-sip + self.sip + ] + ++ lib.optional withConnectivity pkgs.qt5.qtconnectivity + ++ lib.optional withMultimedia pkgs.qt5.qtmultimedia + ++ lib.optional withWebKit pkgs.qt5.qtwebkit + ++ lib.optional withWebSockets pkgs.qt5.qtwebsockets + ; + + buildInputs = old.buildInputs ++ [ + pkgs.dbus + pkgs.qt5.qtbase + pkgs.qt5.qtsvg + pkgs.qt5.qtdeclarative + self.sip + ] + ++ lib.optional withConnectivity pkgs.qt5.qtconnectivity + ++ lib.optional withWebKit pkgs.qt5.qtwebkit + ++ lib.optional withWebSockets pkgs.qt5.qtwebsockets + ; + + # Fix dbus mainloop + patches = pkgs.python3.pkgs.pyqt5.patches or [ ]; + + configurePhase = '' + runHook preConfigure + + export PYTHONPATH=$PYTHONPATH:$out/${self.python.sitePackages} + + mkdir -p $out/${self.python.sitePackages}/dbus/mainloop + ${self.python.executable} configure.py -w \ + --confirm-license \ + --no-qml-plugin \ + --bindir=$out/bin \ + --destdir=$out/${self.python.sitePackages} \ + --stubsdir=$out/${self.python.sitePackages}/PyQt5 \ + --sipdir=$out/share/sip/PyQt5 \ + --designer-plugindir=$out/plugins/designer + + runHook postConfigure + ''; + + postInstall = '' + ln -s ${self.pyqt5-sip}/${self.python.sitePackages}/PyQt5/sip.* $out/${self.python.sitePackages}/PyQt5/ + for i in $out/bin/*; do + wrapProgram $i --prefix PYTHONPATH : "$PYTHONPATH" + done + + # Let's make it a namespace package + cat << EOF > $out/${self.python.sitePackages}/PyQt5/__init__.py + from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) + EOF + ''; + + installCheckPhase = + let + modules = [ + "PyQt5" + "PyQt5.QtCore" + "PyQt5.QtQml" + "PyQt5.QtWidgets" + "PyQt5.QtGui" + ] + ++ lib.optional withWebSockets "PyQt5.QtWebSockets" + ++ lib.optional withWebKit "PyQt5.QtWebKit" + ++ lib.optional withMultimedia "PyQt5.QtMultimedia" + ++ lib.optional withConnectivity "PyQt5.QtConnectivity" + ; + imports = lib.concatMapStrings (module: "import ${module};") modules; + in + '' + echo "Checking whether modules can be imported..." + ${self.python.interpreter} -c "${imports}" + ''; + + doCheck = true; + + enableParallelBuilding = true; + } + ); + + pytest-datadir = super.pytest-datadir.overridePythonAttrs + ( + old: { + postInstall = '' + rm -f $out/LICENSE + ''; + } + ); + + pytest = super.pytest.overridePythonAttrs + ( + old: { + doCheck = false; + } + ); + + pytest-runner = super.pytest-runner or super.pytestrunner; + + python-jose = super.python-jose.overridePythonAttrs + ( + old: { + postPath = '' + substituteInPlace setup.py --replace "'pytest-runner'," "" + substituteInPlace setup.py --replace "'pytest-runner'" "" + ''; + } + ); + + python-prctl = super.python-prctl.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ + pkgs.libcap + ]; + } + ); + + pyzmq = super.pyzmq.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; + propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.zeromq ]; + } + ); + + rockset = super.rockset.overridePythonAttrs + ( + old: rec { + postPatch = '' + cp ./setup_rockset.py ./setup.py + ''; + } + ); + + scaleapi = super.scaleapi.overridePythonAttrs + ( + old: { + postPatch = '' + substituteInPlace setup.py --replace "install_requires = ['requests>=2.4.2', 'enum34']" "install_requires = ['requests>=2.4.2']" || true + ''; + } + ); + + pandas = super.pandas.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ self.cython ]; + } + ); + + # Pybind11 is an undeclared dependency of scipy that we need to pick from nixpkgs + # Make it not fail with infinite recursion + pybind11 = super.pybind11.overridePythonAttrs + ( + old: { + cmakeFlags = (old.cmakeFlags or [ ]) ++ [ + "-DPYBIND11_TEST=off" + ]; + doCheck = false; # Circular test dependency + } + ); + + scipy = super.scipy.overridePythonAttrs + ( + old: { + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ]; + propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pybind11 ]; + setupPyBuildFlags = [ "--fcompiler='gnu95'" ]; + enableParallelBuilding = true; + buildInputs = old.buildInputs ++ [ self.numpy.blas ]; + preConfigure = '' + sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py + export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES + ''; + preBuild = '' + ln -s ${self.numpy.cfg} site.cfg + ''; + } + ); + + scikit-learn = super.scikit-learn.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ [ + pkgs.gfortran + pkgs.glibcLocales + ] ++ lib.optionals stdenv.cc.isClang [ + pkgs.llvmPackages.openmp + ]; nativeBuildInputs = old.nativeBuildInputs ++ [ self.cython - pkgs.pkgconfig - pkgs.cmake ]; - preBuild = '' - export PYARROW_PARALLEL=$NIX_BUILD_CORES - ''; - - PARQUET_HOME = _arrow-cpp; - inherit ARROW_HOME; - - buildInputs = old.buildInputs ++ [ - pkgs.arrow-cpp - ]; - - PYARROW_BUILD_TYPE = "release"; - PYARROW_WITH_PARQUET = true; - PYARROW_CMAKE_OPTIONS = [ - "-DCMAKE_INSTALL_RPATH=${ARROW_HOME}/lib" - - # This doesn't use setup hook to call cmake so we need to workaround #54606 - # ourselves - "-DCMAKE_POLICY_DEFAULT_CMP0025=NEW" - ]; - - dontUseCmakeConfigure = true; - } - ) else super.pyarrow.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ - self.cython - ]; - } - ); - - pycairo = ( - drv: ( - drv.overridePythonAttrs ( - _: { - format = "other"; - } - ) - ).overridePythonAttrs ( - old: { - - nativeBuildInputs = old.nativeBuildInputs ++ [ - pkgs.meson - pkgs.ninja - pkgs.pkgconfig - ]; - - propagatedBuildInputs = old.propagatedBuildInputs ++ [ - pkgs.cairo - pkgs.xlibsWrapper - ]; - - mesonFlags = [ "-Dpython=${if self.isPy3k then "python3" else "python"}" ]; - } - ) - ) super.pycairo; - - pycocotools = super.pycocotools.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - self.cython - self.numpy - ]; - } - ); - - pygobject = super.pygobject.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; - buildInputs = old.buildInputs ++ [ pkgs.glib pkgs.gobject-introspection ]; - } - ); - - pylint = super.pylint.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ self.pytest-runner ]; - doCheck = false; - } - ); - - pyopenssl = super.pyopenssl.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ pkgs.openssl ]; - } - ); - - pyqt5 = let - drv = super.pyqt5; - withConnectivity = drv.passthru.args.withConnectivity or false; - withMultimedia = drv.passthru.args.withMultimedia or false; - withWebKit = drv.passthru.args.withWebKit or false; - withWebSockets = drv.passthru.args.withWebSockets or false; - in - super.pyqt5.overridePythonAttrs ( - old: { - format = "other"; - - nativeBuildInputs = old.nativeBuildInputs ++ [ - pkgs.pkgconfig - pkgs.qt5.qmake - pkgs.xorg.lndir - pkgs.qt5.qtbase - pkgs.qt5.qtsvg - pkgs.qt5.qtdeclarative - pkgs.qt5.qtwebchannel - # self.pyqt5-sip - self.sip - ] - ++ lib.optional withConnectivity pkgs.qt5.qtconnectivity - ++ lib.optional withMultimedia pkgs.qt5.qtmultimedia - ++ lib.optional withWebKit pkgs.qt5.qtwebkit - ++ lib.optional withWebSockets pkgs.qt5.qtwebsockets - ; - - buildInputs = old.buildInputs ++ [ - pkgs.dbus - pkgs.qt5.qtbase - pkgs.qt5.qtsvg - pkgs.qt5.qtdeclarative - self.sip - ] - ++ lib.optional withConnectivity pkgs.qt5.qtconnectivity - ++ lib.optional withWebKit pkgs.qt5.qtwebkit - ++ lib.optional withWebSockets pkgs.qt5.qtwebsockets - ; - - # Fix dbus mainloop - patches = pkgs.python3.pkgs.pyqt5.patches or []; - - configurePhase = '' - runHook preConfigure - - export PYTHONPATH=$PYTHONPATH:$out/${self.python.sitePackages} - - mkdir -p $out/${self.python.sitePackages}/dbus/mainloop - ${self.python.executable} configure.py -w \ - --confirm-license \ - --no-qml-plugin \ - --bindir=$out/bin \ - --destdir=$out/${self.python.sitePackages} \ - --stubsdir=$out/${self.python.sitePackages}/PyQt5 \ - --sipdir=$out/share/sip/PyQt5 \ - --designer-plugindir=$out/plugins/designer - - runHook postConfigure - ''; - - postInstall = '' - ln -s ${self.pyqt5-sip}/${self.python.sitePackages}/PyQt5/sip.* $out/${self.python.sitePackages}/PyQt5/ - for i in $out/bin/*; do - wrapProgram $i --prefix PYTHONPATH : "$PYTHONPATH" - done - - # Let's make it a namespace package - cat << EOF > $out/${self.python.sitePackages}/PyQt5/__init__.py - from pkgutil import extend_path - __path__ = extend_path(__path__, __name__) - EOF - ''; - - installCheckPhase = let - modules = [ - "PyQt5" - "PyQt5.QtCore" - "PyQt5.QtQml" - "PyQt5.QtWidgets" - "PyQt5.QtGui" - ] - ++ lib.optional withWebSockets "PyQt5.QtWebSockets" - ++ lib.optional withWebKit "PyQt5.QtWebKit" - ++ lib.optional withMultimedia "PyQt5.QtMultimedia" - ++ lib.optional withConnectivity "PyQt5.QtConnectivity" - ; - - imports = lib.concatMapStrings (module: "import ${module};") modules; - in - '' - echo "Checking whether modules can be imported..." - ${self.python.interpreter} -c "${imports}" - ''; - - doCheck = true; - enableParallelBuilding = true; } ); - pytest-datadir = super.pytest-datadir.overridePythonAttrs ( - old: { - postInstall = '' - rm -f $out/LICENSE - ''; - } - ); - - pytest = super.pytest.overridePythonAttrs ( - old: { - doCheck = false; - } - ); - - pytest-runner = super.pytest-runner or super.pytestrunner; - - python-jose = super.python-jose.overridePythonAttrs ( - old: { - postPath = '' - substituteInPlace setup.py --replace "'pytest-runner'," "" - substituteInPlace setup.py --replace "'pytest-runner'" "" - ''; - } - ); - - python-prctl = super.python-prctl.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - pkgs.libcap - ]; - } - ); - - pyzmq = super.pyzmq.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; - propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.zeromq ]; - } - ); - - rockset = super.rockset.overridePythonAttrs ( - old: rec { - postPatch = '' - cp ./setup_rockset.py ./setup.py - ''; - } - ); - - scaleapi = super.scaleapi.overridePythonAttrs ( - old: { - postPatch = '' - substituteInPlace setup.py --replace "install_requires = ['requests>=2.4.2', 'enum34']" "install_requires = ['requests>=2.4.2']" || true - ''; - } - ); - - pandas = super.pandas.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ self.cython ]; - } - ); - - # Pybind11 is an undeclared dependency of scipy that we need to pick from nixpkgs - # Make it not fail with infinite recursion - pybind11 = super.pybind11.overridePythonAttrs ( - old: { - cmakeFlags = (old.cmakeFlags or []) ++ [ - "-DPYBIND11_TEST=off" - ]; - doCheck = false; # Circular test dependency - } - ); - - scipy = super.scipy.overridePythonAttrs ( - old: { - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ]; - propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pybind11 ]; - setupPyBuildFlags = [ "--fcompiler='gnu95'" ]; - enableParallelBuilding = true; - buildInputs = old.buildInputs ++ [ self.numpy.blas ]; - preConfigure = '' - sed -i '0,/from numpy.distutils.core/s//import setuptools;from numpy.distutils.core/' setup.py - export NPY_NUM_BUILD_JOBS=$NIX_BUILD_CORES - ''; - preBuild = '' - ln -s ${self.numpy.cfg} site.cfg - ''; - } - ); - - scikit-learn = super.scikit-learn.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ - pkgs.gfortran - pkgs.glibcLocales - ] ++ lib.optionals stdenv.cc.isClang [ - pkgs.llvmPackages.openmp - ]; - - nativeBuildInputs = old.nativeBuildInputs ++ [ - self.cython - ]; - - enableParallelBuilding = true; - } - ); - - shapely = super.shapely.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ [ pkgs.geos self.cython ]; - inherit (pkgs.python3.pkgs.shapely) patches GEOS_LIBRARY_PATH; - } - ); - - shellingham = if lib.versionAtLeast super.shellingham.version "1.3.2" then ( - super.shellingham.overridePythonAttrs ( + shapely = super.shapely.overridePythonAttrs + ( old: { - format = "pyproject"; + buildInputs = old.buildInputs ++ [ pkgs.geos self.cython ]; + inherit (pkgs.python3.pkgs.shapely) patches GEOS_LIBRARY_PATH; } - ) - ) else super.shellingham; + ); - tables = super.tables.overridePythonAttrs ( - old: { - HDF5_DIR = "${pkgs.hdf5}"; - nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; - propagatedBuildInputs = old.nativeBuildInputs ++ [ pkgs.hdf5 self.numpy self.numexpr ]; - } - ); + shellingham = + if lib.versionAtLeast super.shellingham.version "1.3.2" then ( + super.shellingham.overridePythonAttrs + ( + old: { + format = "pyproject"; + } + ) + ) else super.shellingham; - tensorpack = super.tensorpack.overridePythonAttrs ( - old: { - postPatch = '' - substituteInPlace setup.cfg --replace "# will call find_packages()" "" - ''; - } - ); + tables = super.tables.overridePythonAttrs + ( + old: { + HDF5_DIR = "${pkgs.hdf5}"; + nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; + propagatedBuildInputs = old.nativeBuildInputs ++ [ pkgs.hdf5 self.numpy self.numexpr ]; + } + ); - urwidtrees = super.urwidtrees.overridePythonAttrs ( - old: { - propagatedBuildInputs = old.propagatedBuildInputs ++ [ - self.urwid - ]; - } - ); + tensorpack = super.tensorpack.overridePythonAttrs + ( + old: { + postPatch = '' + substituteInPlace setup.cfg --replace "# will call find_packages()" "" + ''; + } + ); - vose-alias-method = super.vose-alias-method.overridePythonAttrs ( - old: { - postInstall = '' - rm -f $out/LICENSE - ''; - } - ); + urwidtrees = super.urwidtrees.overridePythonAttrs + ( + old: { + propagatedBuildInputs = old.propagatedBuildInputs ++ [ + self.urwid + ]; + } + ); - uvloop = super.uvloop.overridePythonAttrs ( - old: { - buildInputs = old.buildInputs ++ lib.optionals stdenv.isDarwin [ - pkgs.darwin.apple_sdk.frameworks.ApplicationServices - pkgs.darwin.apple_sdk.frameworks.CoreServices - ]; - } - ); + vose-alias-method = super.vose-alias-method.overridePythonAttrs + ( + old: { + postInstall = '' + rm -f $out/LICENSE + ''; + } + ); + + uvloop = super.uvloop.overridePythonAttrs + ( + old: { + buildInputs = old.buildInputs ++ lib.optionals stdenv.isDarwin [ + pkgs.darwin.apple_sdk.frameworks.ApplicationServices + pkgs.darwin.apple_sdk.frameworks.CoreServices + ]; + } + ); # Stop infinite recursion by using bootstrapped pkg from nixpkgs wheel = ( pkgs.python3.pkgs.override { python = self.python; } - ).wheel.overridePythonAttrs ( - _: { - inherit (super.wheel) pname name version src; - } - ); + ).wheel.overridePythonAttrs + ( + _: { + inherit (super.wheel) pname name version src; + } + ); zipp = ( if lib.versionAtLeast super.zipp.version "2.0.0" then ( - super.zipp.overridePythonAttrs ( - old: { - prePatch = '' - substituteInPlace setup.py --replace \ - 'setuptools.setup()' \ - 'setuptools.setup(version="${super.zipp.version}")' - ''; - } - ) + super.zipp.overridePythonAttrs + ( + old: { + prePatch = '' + substituteInPlace setup.py --replace \ + 'setuptools.setup()' \ + 'setuptools.setup(version="${super.zipp.version}")' + ''; + } + ) ) else super.zipp - ).overridePythonAttrs ( - old: { - propagatedBuildInputs = old.propagatedBuildInputs ++ [ - self.toml - ]; - } - ); + ).overridePythonAttrs + ( + old: { + propagatedBuildInputs = old.propagatedBuildInputs ++ [ + self.toml + ]; + } + ); } diff --git a/pep425.nix b/pep425.nix index 6b63146..496c4ff 100644 --- a/pep425.nix +++ b/pep425.nix @@ -12,8 +12,7 @@ let major = builtins.elemAt ver 0; minor = builtins.elemAt ver 1; in - "cp${major}${minor}"; - + "cp${major}${minor}"; abiTag = "${pythonTag}m"; # @@ -24,13 +23,13 @@ let entries = splitString "-" str; p = removeSuffix ".whl" (builtins.elemAt entries 4); in - { - pkgName = builtins.elemAt entries 0; - pkgVer = builtins.elemAt entries 1; - pyVer = builtins.elemAt entries 2; - abi = builtins.elemAt entries 3; - platform = p; - }; + { + pkgName = builtins.elemAt entries 0; + pkgVer = builtins.elemAt entries 1; + pyVer = builtins.elemAt entries 2; + abi = builtins.elemAt entries 3; + platform = p; + }; # # Builds list of acceptable osx wheel files @@ -42,9 +41,9 @@ let v = lib.lists.head versions; vs = lib.lists.tail versions; in - if (builtins.length versions == 0) - then [] - else (builtins.filter (x: hasInfix v x.file) candidates) ++ (findBestMatches vs candidates); + if (builtins.length versions == 0) + then [ ] + else (builtins.filter (x: hasInfix v x.file) candidates) ++ (findBestMatches vs candidates); # pyver = "cpXX" # x = "cpXX" | "py2" | "py3" | "py2.py3" @@ -53,7 +52,7 @@ let normalize = y: ''cp${lib.strings.removePrefix "cp" (lib.strings.removePrefix "py" y)}''; isCompat = p: x: lib.strings.hasPrefix (normalize x) p; 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 @@ -61,28 +60,23 @@ let selectWheel = files: let filesWithoutSources = (builtins.filter (x: hasSuffix ".whl" x.file) files); - isPyAbiCompatible = pyabi: x: x == "none" || pyabi == x; - withPython = ver: abi: x: (isPyVersionCompatible ver x.pyVer) && (isPyAbiCompatible abi x.abi); - - withPlatform = if isLinux - then ( - x: x.platform == "manylinux1_${stdenv.platform.kernelArch}" - || x.platform == "manylinux2010_${stdenv.platform.kernelArch}" - || x.platform == "manylinux2014_${stdenv.platform.kernelArch}" - || x.platform == "any" - ) - else (x: hasInfix "macosx" x.platform || x.platform == "any"); - + withPlatform = + if isLinux + then ( + x: x.platform == "manylinux1_${stdenv.platform.kernelArch}" + || x.platform == "manylinux2010_${stdenv.platform.kernelArch}" + || x.platform == "manylinux2014_${stdenv.platform.kernelArch}" + || x.platform == "any" + ) + else (x: hasInfix "macosx" x.platform || x.platform == "any"); filterWheel = x: let f = toWheelAttrs x.file; in - (withPython pythonTag abiTag f) && (withPlatform f); - + (withPython pythonTag abiTag f) && (withPlatform f); filtered = builtins.filter filterWheel filesWithoutSources; - choose = files: let osxMatches = [ "10_12" "10_11" "10_10" "10_9" "any" ]; @@ -90,13 +84,13 @@ let chooseLinux = x: lib.take 1 (findBestMatches linuxMatches x); chooseOSX = x: lib.take 1 (findBestMatches osxMatches x); in - if isLinux - then chooseLinux files - else chooseOSX files; + if isLinux + then chooseLinux files + else chooseOSX files; in - if (builtins.length filtered == 0) - then [] - else choose (filtered); + if (builtins.length filtered == 0) + then [ ] + else choose (filtered); in { inherit selectWheel toWheelAttrs isPyVersionCompatible; diff --git a/pep508.nix b/pep508.nix index 67ffddd..e833747 100644 --- a/pep508.nix +++ b/pep508.nix @@ -7,7 +7,6 @@ let # Strip leading/trailing whitespace from string stripStr = s: lib.elemAt (builtins.split "^ *" (lib.elemAt (builtins.split " *$" s) 0)) 2; - findSubExpressionsFun = acc: c: ( if c == "(" then ( let @@ -15,23 +14,23 @@ let isOpen = acc.openP == 0; startPos = if isOpen then posNew else acc.startPos; in - acc // { - inherit startPos; - exprs = acc.exprs ++ [ (substr acc.exprPos (acc.pos - 1) acc.expr) ]; - pos = posNew; - openP = acc.openP + 1; - } + acc // { + inherit startPos; + exprs = acc.exprs ++ [ (substr acc.exprPos (acc.pos - 1) acc.expr) ]; + pos = posNew; + openP = acc.openP + 1; + } ) else if c == ")" then ( let openP = acc.openP - 1; exprs = findSubExpressions (substr acc.startPos acc.pos acc.expr); in - acc // { - inherit openP; - pos = acc.pos + 1; - exprs = if openP == 0 then acc.exprs ++ [ exprs ] else acc.exprs; - exprPos = if openP == 0 then acc.pos + 1 else acc.exprPos; - } + acc // { + inherit openP; + pos = acc.pos + 1; + exprs = if openP == 0 then acc.exprs ++ [ exprs ] else acc.exprs; + exprPos = if openP == 0 then acc.pos + 1 else acc.exprPos; + } ) else acc // { pos = acc.pos + 1; } ); @@ -39,7 +38,7 @@ let findSubExpressions = expr: let acc = builtins.foldl' findSubExpressionsFun { - exprs = []; + exprs = [ ]; expr = expr; pos = 0; openP = 0; @@ -47,18 +46,16 @@ let startPos = 0; } (lib.stringToCharacters expr); tailExpr = (substr acc.exprPos acc.pos expr); - tailExprs = if tailExpr != "" then [ tailExpr ] else []; + tailExprs = if tailExpr != "" then [ tailExpr ] else [ ]; in - acc.exprs ++ tailExprs; - + acc.exprs ++ tailExprs; parseExpressions = exprs: let splitCond = ( 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 + " ")) ); - mapfn = expr: ( if (builtins.match "^ ?$" expr != null) then null # Filter empty else if (builtins.elem expr [ "and" "or" ]) then { @@ -70,14 +67,13 @@ let value = expr; } ); - parse = expr: builtins.filter (x: x != null) (builtins.map mapfn (splitCond expr)); in - builtins.foldl' ( - acc: v: acc ++ ( - if builtins.typeOf v == "string" then parse v else [ (parseExpressions v) ] + builtins.foldl' + ( + acc: v: acc ++ ( if builtins.typeOf v == "string" then parse v else [ (parseExpressions v) ] ) - ) [] exprs; + ) [ ] exprs; # Transform individual expressions to structured expressions # This function also performs variable substitution, replacing environment markers with their explicit values @@ -94,9 +90,10 @@ let else throw "Unsupported platform" ); platform_machine = stdenv.platform.kernelArch; - platform_python_implementation = let - impl = python.passthru.implementation; - in + platform_python_implementation = + let + impl = python.passthru.implementation; + in ( if impl == "cpython" then "CPython" else if impl == "pypy" then "PyPy" @@ -115,34 +112,32 @@ let implementation_version = python.version; extra = ""; }; - substituteVar = value: if builtins.hasAttr value variables then (builtins.toJSON variables."${value}") else value; - processVar = value: builtins.foldl' (acc: v: v acc) value [ stripStr substituteVar ]; in - if builtins.typeOf exprs == "set" then ( - if exprs.type == "expr" then ( - let - mVal = ''[a-zA-Z0-9\'"_\. ]+''; - mOp = "in|[!=<>]+"; - e = stripStr exprs.value; - m = builtins.map stripStr (builtins.match ''^(${mVal}) *(${mOp}) *(${mVal})$'' e); - in - { - type = "expr"; - value = { - op = builtins.elemAt m 1; - values = [ - (processVar (builtins.elemAt m 0)) - (processVar (builtins.elemAt m 2)) - ]; - }; - } - ) else exprs - ) else builtins.map transformExpressions exprs; + if builtins.typeOf exprs == "set" then ( + if exprs.type == "expr" then ( + let + mVal = ''[a-zA-Z0-9\'"_\. ]+''; + mOp = "in|[!=<>]+"; + e = stripStr exprs.value; + m = builtins.map stripStr (builtins.match ''^(${mVal}) *(${mOp}) *(${mVal})$'' e); + in + { + type = "expr"; + value = { + op = builtins.elemAt m 1; + values = [ + (processVar (builtins.elemAt m 0)) + (processVar (builtins.elemAt m 2)) + ]; + }; + } + ) else exprs + ) else builtins.map transformExpressions exprs; # Recursively eval all expressions evalExpressions = exprs: @@ -165,32 +160,33 @@ let let parts = builtins.splitVersion c; pruned = lib.take ((builtins.length parts) - 1) parts; - upper = builtins.toString ( - (lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1 - ); + upper = builtins.toString + ( + (lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1 + ); upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned); in - op.">=" v c && op."<" v upperConstraint; + op.">=" v c && op."<" v upperConstraint; "===" = x: y: x == y; "in" = x: y: let values = builtins.filter (x: builtins.typeOf x == "string") (builtins.split " " (unmarshal y)); in - builtins.elem (unmarshal x) values; + builtins.elem (unmarshal x) values; }; in - if builtins.typeOf exprs == "set" then ( - if exprs.type == "expr" then ( - let - expr = exprs; - result = (op."${expr.value.op}") (builtins.elemAt expr.value.values 0) (builtins.elemAt expr.value.values 1); - in - { - type = "value"; - value = result; - } - ) else exprs - ) else builtins.map evalExpressions exprs; + if builtins.typeOf exprs == "set" then ( + if exprs.type == "expr" then ( + let + expr = exprs; + result = (op."${expr.value.op}") (builtins.elemAt expr.value.values 0) (builtins.elemAt expr.value.values 1); + in + { + type = "value"; + value = result; + } + ) else 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 reduceExpressions = exprs: @@ -217,18 +213,18 @@ let cond = "and"; } v; in - acc // { - value = cond."${acc.cond}" acc.value ret.value; - } + acc // { + value = cond."${acc.cond}" acc.value ret.value; + } ) else throw "Unsupported type" ); in - ( - builtins.foldl' reduceExpressionsFun { - value = true; - cond = "and"; - } exprs - ).value; + ( + builtins.foldl' reduceExpressionsFun { + value = true; + cond = "and"; + } exprs + ).value; in e: builtins.foldl' (acc: v: v acc) e [ findSubExpressions diff --git a/semver.nix b/semver.nix index 07dcbbc..e86b1d3 100644 --- a/semver.nix +++ b/semver.nix @@ -1,28 +1,28 @@ { lib, ireplace }: let inherit (builtins) elemAt match; - - operators = let - matchWildCard = s: match "([^\*])(\.[\*])" s; - mkComparison = ret: version: v: builtins.compareVersions version v == ret; - mkIdxComparison = idx: version: v: - let - ver = builtins.splitVersion v; - minor = builtins.toString (lib.toInt (elemAt ver idx) + 1); - upper = builtins.concatStringsSep "." (ireplace idx minor ver); - in + operators = + let + matchWildCard = s: match "([^\*])(\.[\*])" s; + mkComparison = ret: version: v: builtins.compareVersions version v == ret; + mkIdxComparison = idx: version: v: + let + ver = builtins.splitVersion v; + minor = builtins.toString (lib.toInt (elemAt ver idx) + 1); + upper = builtins.concatStringsSep "." (ireplace idx minor ver); + in operators.">=" version v && operators."<" version upper; - dropWildcardPrecision = f: version: constraint: - let - m = matchWildCard constraint; - hasWildcard = m != null; - c = if hasWildcard then (elemAt m 0) else constraint; - v = - if hasWildcard then (builtins.substring 0 (builtins.stringLength c) version) - else version; - in + dropWildcardPrecision = f: version: constraint: + let + m = matchWildCard constraint; + hasWildcard = m != null; + c = if hasWildcard then (elemAt m 0) else constraint; + v = + if hasWildcard then (builtins.substring 0 (builtins.stringLength c) version) + else version; + in f v c; - in + in { # Prefix operators "==" = dropWildcardPrecision (mkComparison 0); @@ -39,24 +39,23 @@ let # Prune constraint parts = builtins.splitVersion c; pruned = lib.take ((builtins.length parts) - 1) parts; - upper = builtins.toString ( - (lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1 - ); + upper = builtins.toString + ( + (lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1 + ); upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned); in - operators.">=" v c && operators."<" v upperConstraint; + operators.">=" v c && operators."<" v upperConstraint; # Infix operators "-" = version: v: operators.">=" version v.vl && operators."<=" version v.vu; # Arbitrary equality clause, just run simple comparison "===" = v: c: v == c; # }; - re = { operators = "([=> {} }: +{ pkgs ? import { } }: let poetry = pkgs.callPackage ../pkgs/poetry { python = pkgs.python3; inherit poetry2nix; }; poetry2nix = import ./.. { inherit pkgs; inherit poetry; }; - - pep425 = pkgs.callPackage ../pep425.nix {}; + pep425 = pkgs.callPackage ../pep425.nix { }; pep425Python37 = pkgs.callPackage ../pep425.nix { python = pkgs.python37; }; pep425OSX = pkgs.callPackage ../pep425.nix { isLinux = false; }; - skipTests = builtins.filter (t: builtins.typeOf t != "list") (builtins.split "," (builtins.getEnv "SKIP_TESTS")); - callTest = test: attrs: pkgs.callPackage test ({ inherit poetry2nix; } // attrs); in builtins.removeAttrs - { - trivial = callTest ./trivial {}; - override = callTest ./override-support {}; - override-default = callTest ./override-default-support {}; - top-packages-1 = callTest ./common-pkgs-1 {}; - top-packages-2 = callTest ./common-pkgs-2 {}; - pep425 = pkgs.callPackage ./pep425 { inherit pep425; inherit pep425OSX; inherit pep425Python37; }; - env = callTest ./env {}; - git-deps = callTest ./git-deps {}; - git-deps-pinned = callTest ./git-deps-pinned {}; - cli = poetry2nix; - path-deps = callTest ./path-deps {}; - path-deps-level2 = callTest ./path-deps-level2 {}; - operators = callTest ./operators {}; - preferWheel = callTest ./prefer-wheel {}; - prefer-wheels = callTest ./prefer-wheels {}; - 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 +{ + trivial = callTest ./trivial { }; + override = callTest ./override-support { }; + override-default = callTest ./override-default-support { }; + top-packages-1 = callTest ./common-pkgs-1 { }; + top-packages-2 = callTest ./common-pkgs-2 { }; + pep425 = pkgs.callPackage ./pep425 { inherit pep425; inherit pep425OSX; inherit pep425Python37; }; + env = callTest ./env { }; + git-deps = callTest ./git-deps { }; + git-deps-pinned = callTest ./git-deps-pinned { }; + cli = poetry2nix; + path-deps = callTest ./path-deps { }; + path-deps-level2 = callTest ./path-deps-level2 { }; + operators = callTest ./operators { }; + preferWheel = callTest ./prefer-wheel { }; + prefer-wheels = callTest ./prefer-wheels { }; + closure-size = callTest ./closure-size { 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 - # poetry-pypy = poetry.override { python = pkgs.pypy; }; - # poetry-pypy3 = poetry.override { python = pkgs.pypy3; }; + # Test building poetry + inherit poetry; + poetry-python2 = poetry.override { python = pkgs.python2; }; - # 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 + # And also test with pypy + # poetry-pypy = poetry.override { python = pkgs.pypy; }; + # poetry-pypy3 = poetry.override { python = pkgs.pypy3; }; + + # 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 diff --git a/tests/eggs/default.nix b/tests/eggs/default.nix index 7159713..085e3be 100644 --- a/tests/eggs/default.nix +++ b/tests/eggs/default.nix @@ -7,7 +7,7 @@ let src = lib.cleanSource ./.; }; in -runCommandNoCC "egg-test" {} '' +runCommandNoCC "egg-test" { } '' ${drv}/bin/egg-test touch $out '' diff --git a/tests/env/default.nix b/tests/env/default.nix index ad12aa2..ecbaf29 100644 --- a/tests/env/default.nix +++ b/tests/env/default.nix @@ -6,7 +6,7 @@ let poetrylock = ./poetry.lock; }; in -runCommand "env-test" {} '' +runCommand "env-test" { } '' ${env}/bin/python -c 'import alembic' touch $out '' diff --git a/tests/git-deps-pinned/poetry-git-overlay.nix b/tests/git-deps-pinned/poetry-git-overlay.nix index 62537b6..0e7f647 100644 --- a/tests/git-deps-pinned/poetry-git-overlay.nix +++ b/tests/git-deps-pinned/poetry-git-overlay.nix @@ -1,14 +1,15 @@ { pkgs }: self: super: { - alembic = super.alembic.overrideAttrs ( - _: { - src = pkgs.fetchgit { - url = "https://github.com/sqlalchemy/alembic.git"; - rev = "8d6bb007a4de046c4d338f4b79b40c9fcbf73ab7"; - sha256 = "15q4dsn4b1cjf1a4cxymxl2gzdjnv9zlndk98jmpfhssqsr4ky3w"; - }; - } - ); + alembic = super.alembic.overrideAttrs + ( + _: { + src = pkgs.fetchgit { + url = "https://github.com/sqlalchemy/alembic.git"; + rev = "8d6bb007a4de046c4d338f4b79b40c9fcbf73ab7"; + sha256 = "15q4dsn4b1cjf1a4cxymxl2gzdjnv9zlndk98jmpfhssqsr4ky3w"; + }; + } + ); } diff --git a/tests/manylinux/default.nix b/tests/manylinux/default.nix index 0aa9f9c..d30f266 100644 --- a/tests/manylinux/default.nix +++ b/tests/manylinux/default.nix @@ -8,7 +8,7 @@ let }; p = pkg.python.withPackages (ps: [ ps.numpy ps.opencv-python ]); in -runCommand "test" {} '' +runCommand "test" { } '' ${p}/bin/python -c "import cv2" touch $out '' diff --git a/tests/override-default-support/default.nix b/tests/override-default-support/default.nix index 456fae0..7fd83be 100644 --- a/tests/override-default-support/default.nix +++ b/tests/override-default-support/default.nix @@ -7,20 +7,22 @@ let pyproject = ./pyproject.toml; overrides = [ ( - poetry2nix.defaultPoetryOverrides.overrideOverlay ( - self: super: { - alembic = super.alembic.overrideAttrs ( - old: { - TESTING_FOOBAR = 42; - } - ); - } - ) + poetry2nix.defaultPoetryOverrides.overrideOverlay + ( + self: super: { + alembic = super.alembic.overrideAttrs + ( + old: { + TESTING_FOOBAR = 42; + } + ); + } + ) ) ]; }; in -runCommand "test" {} '' +runCommand "test" { } '' x=${builtins.toString (p.python.pkgs.alembic.TESTING_FOOBAR)} [ "$x" = "42" ] || exit 1 mkdir $out diff --git a/tests/override-support/default.nix b/tests/override-support/default.nix index c454548..631a750 100644 --- a/tests/override-support/default.nix +++ b/tests/override-support/default.nix @@ -8,16 +8,17 @@ let overrides = poetry2nix.overrides.withDefaults ( self: super: { - alembic = super.alembic.overrideAttrs ( - old: { - TESTING_FOOBAR = 42; - } - ); + alembic = super.alembic.overrideAttrs + ( + old: { + TESTING_FOOBAR = 42; + } + ); } ); }; in -runCommand "test" {} '' +runCommand "test" { } '' x=${builtins.toString (p.python.pkgs.alembic.TESTING_FOOBAR)} [ "$x" = "42" ] || exit 1 mkdir $out diff --git a/tests/pep425/default.nix b/tests/pep425/default.nix index 623cb57..7b5bde0 100644 --- a/tests/pep425/default.nix +++ b/tests/pep425/default.nix @@ -13,10 +13,10 @@ lib.debug.runTests { { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } ]; in - { - expr = (pep425.selectWheel cs); - expected = [ { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } ]; - }; + { + expr = (pep425.selectWheel cs); + expected = [{ file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; }]; + }; testOSXSimple = let @@ -25,10 +25,10 @@ lib.debug.runTests { { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } ]; in - { - expr = (pep425OSX.selectWheel cs); - expected = [ { file = "grpcio-1.25.0-cp27-cp27m-macosx_10_10_x86_64.whl"; } ]; - }; + { + expr = (pep425OSX.selectWheel cs); + expected = [{ file = "grpcio-1.25.0-cp27-cp27m-macosx_10_10_x86_64.whl"; }]; + }; testLinuxPickPython37 = let @@ -41,10 +41,10 @@ lib.debug.runTests { { file = "grpcio-1.25.0-cp37-cp37m-manylinux2010_x86_64.whl"; } ]; in - { - expr = (pep425Python37.selectWheel cs); - expected = [ { file = "grpcio-1.25.0-cp37-cp37m-manylinux2010_x86_64.whl"; } ]; - }; + { + expr = (pep425Python37.selectWheel cs); + expected = [{ file = "grpcio-1.25.0-cp37-cp37m-manylinux2010_x86_64.whl"; }]; + }; testOSXPreferNewer = let @@ -53,10 +53,10 @@ lib.debug.runTests { { file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; } ]; in - { - expr = (pep425OSX.selectWheel cs); - expected = [ { file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; } ]; - }; + { + expr = (pep425OSX.selectWheel cs); + expected = [{ file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; }]; + }; testOSXNoMatch = let @@ -65,10 +65,10 @@ lib.debug.runTests { { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } ]; in - { - expr = (pep425OSX.selectWheel cs); - expected = []; - }; + { + expr = (pep425OSX.selectWheel cs); + expected = [ ]; + }; testLinuxPreferOlder = let @@ -77,10 +77,10 @@ lib.debug.runTests { { file = "grpcio-1.25.0-cp27-cp27m-manylinux2010_x86_64.whl"; } ]; in - { - expr = (pep425.selectWheel cs); - expected = [ { file = "grpcio-1.25.0-cp27-cp27m-manylinux1_x86_64.whl"; } ]; - }; + { + expr = (pep425.selectWheel cs); + expected = [{ file = "grpcio-1.25.0-cp27-cp27m-manylinux1_x86_64.whl"; }]; + }; testLinuxNoMatch = let @@ -89,19 +89,19 @@ lib.debug.runTests { { file = "grpcio-1.25.0-cp27-cp27m-macosx_10_12_x86_64.whl"; } ]; in - { - expr = (pep425.selectWheel cs); - expected = []; - }; + { + expr = (pep425.selectWheel cs); + expected = [ ]; + }; testLinuxEmptyList = { - expr = pep425.selectWheel []; - expected = []; + expr = pep425.selectWheel [ ]; + expected = [ ]; }; testOSXEmptyList = { - expr = pep425OSX.selectWheel []; - expected = []; + expr = pep425OSX.selectWheel [ ]; + expected = [ ]; }; testLinuxCffiWhlFiles = @@ -142,10 +142,10 @@ lib.debug.runTests { { file = "cffi-1.13.2.tar.gz"; } ]; in - { - expr = pep425.selectWheel cs; - expected = [ { file = "cffi-1.13.2-cp27-cp27m-manylinux1_x86_64.whl"; } ]; - }; + { + expr = pep425.selectWheel cs; + expected = [{ file = "cffi-1.13.2-cp27-cp27m-manylinux1_x86_64.whl"; }]; + }; testMsgPack = let @@ -173,10 +173,10 @@ lib.debug.runTests { { file = "msgpack-0.6.2.tar.gz"; } ]; in - { - expr = pep425Python37.selectWheel cs; - expected = [ { file = "msgpack-0.6.2-cp37-cp37m-manylinux1_x86_64.whl"; } ]; - }; + { + expr = pep425Python37.selectWheel cs; + expected = [{ file = "msgpack-0.6.2-cp37-cp37m-manylinux1_x86_64.whl"; }]; + }; testNonManyLinuxWheels = let @@ -185,10 +185,10 @@ lib.debug.runTests { { file = "tensorboard-1.14.0-py3-none-any.whl"; } ]; in - { - expr = pep425Python37.selectWheel cs; - expected = [ { file = "tensorboard-1.14.0-py3-none-any.whl"; } ]; - }; + { + expr = pep425Python37.selectWheel cs; + expected = [{ file = "tensorboard-1.14.0-py3-none-any.whl"; }]; + }; testPy2Py3Wheels = let @@ -196,10 +196,10 @@ lib.debug.runTests { { file = "tensorboard-1.14.0-py2.py3-none-any.whl"; } ]; in - { - expr = pep425Python37.selectWheel cs; - expected = [ { file = "tensorboard-1.14.0-py2.py3-none-any.whl"; } ]; - }; + { + expr = pep425Python37.selectWheel cs; + expected = [{ file = "tensorboard-1.14.0-py2.py3-none-any.whl"; }]; + }; # # toWheelAttrs @@ -209,31 +209,31 @@ lib.debug.runTests { let name = "msgpack-0.6.2-cp27-cp27m-manylinux1_i686.whl"; in - { - expr = pep425.toWheelAttrs name; - expected = { - pkgName = "msgpack"; - pkgVer = "0.6.2"; - pyVer = "cp27"; - abi = "cp27m"; - platform = "manylinux1_i686"; - }; + { + expr = pep425.toWheelAttrs name; + expected = { + pkgName = "msgpack"; + pkgVer = "0.6.2"; + pyVer = "cp27"; + abi = "cp27m"; + platform = "manylinux1_i686"; }; + }; testToWheelAttrsAny = let name = "tensorboard-1.14.0-py3-none-any.whl"; in - { - expr = pep425.toWheelAttrs name; - expected = { - pkgName = "tensorboard"; - pkgVer = "1.14.0"; - pyVer = "py3"; - abi = "none"; - platform = "any"; - }; + { + expr = pep425.toWheelAttrs name; + expected = { + pkgName = "tensorboard"; + pkgVer = "1.14.0"; + pyVer = "py3"; + abi = "none"; + platform = "any"; }; + }; # # isPyVersionCompatible @@ -243,23 +243,23 @@ lib.debug.runTests { let f = pep425.isPyVersionCompatible; in - { - expr = [ - (f "cp27" "cp27") - (f "cp27" "cp37") - (f "cp27" "py2") - (f "cp27" "py3") - (f "cp27" "py2.py3") - (f "cp37" "py2.py3") - ]; + { + expr = [ + (f "cp27" "cp27") + (f "cp27" "cp37") + (f "cp27" "py2") + (f "cp27" "py3") + (f "cp27" "py2.py3") + (f "cp37" "py2.py3") + ]; - expected = [ - true - false - true - false - true - ]; - }; + expected = [ + true + false + true + false + true + ]; + }; } diff --git a/tests/prefer-wheel/default.nix b/tests/prefer-wheel/default.nix index 926f59d..6ff6e36 100644 --- a/tests/prefer-wheel/default.nix +++ b/tests/prefer-wheel/default.nix @@ -15,7 +15,6 @@ let } ); }; - url = lib.elemAt drv.passthru.python.pkgs.maturin.src.urls 0; in assert lib.hasSuffix "whl" url; drv diff --git a/tests/prefer-wheels/default.nix b/tests/prefer-wheels/default.nix index aeca2c3..3eca0b3 100644 --- a/tests/prefer-wheels/default.nix +++ b/tests/prefer-wheels/default.nix @@ -1,14 +1,11 @@ { lib, poetry2nix, python3, runCommand }: let - app = poetry2nix.mkPoetryApplication { projectDir = ./.; preferWheels = true; }; - url = lib.elemAt app.passthru.python.pkgs.tensorflow.src.urls 0; - in -assert lib.hasSuffix "whl" url; runCommand "prefer-wheels" {} '' - touch $out -'' + assert lib.hasSuffix "whl" url; runCommand "prefer-wheels" { } '' + touch $out + '' diff --git a/tests/source-filter/default.nix b/tests/source-filter/default.nix index efce6ce..82b4a31 100644 --- a/tests/source-filter/default.nix +++ b/tests/source-filter/default.nix @@ -5,9 +5,10 @@ poetry2nix.mkPoetryApplication { projectDir = ./.; # Assert expected ignored files not in sources - preConfigure = let - assertNotExists = name: "! test -f ${name} || (echo ${name} exists && false)"; - in + preConfigure = + let + assertNotExists = name: "! test -f ${name} || (echo ${name} exists && false)"; + in '' ${assertNotExists "ignored.pyc"} ${assertNotExists "__pycache__"} diff --git a/tools/default.nix b/tools/default.nix index 6155fb7..a237d66 100644 --- a/tools/default.nix +++ b/tools/default.nix @@ -11,13 +11,15 @@ let in { - release = let - pythonEnv = pkgs.python3.withPackages ( - ps: [ - ps.pythonix - ] - ); - in + release = + let + pythonEnv = pkgs.python3.withPackages + ( + ps: [ + ps.pythonix + ] + ); + in pkgs.writeScriptBin "poetry2nix-release" '' #!${pythonEnv.interpreter} import subprocess @@ -47,18 +49,18 @@ in exit(p.returncode) ''; - flamegraph = let - runtimeDeps = lib.makeBinPath [ - pkgs.flamegraph - pkgs.python3 - pkgs.nix - ]; - - nixSrc = pkgs.runCommandNoCC "${pkgs.nix.name}-sources" {} '' - mkdir $out - tar -x --strip=1 -f ${pkgs.nix.src} -C $out - ''; - in + flamegraph = + let + runtimeDeps = lib.makeBinPath [ + pkgs.flamegraph + pkgs.python3 + pkgs.nix + ]; + nixSrc = pkgs.runCommandNoCC "${pkgs.nix.name}-sources" { } '' + mkdir $out + tar -x --strip=1 -f ${pkgs.nix.src} -C $out + ''; + in pkgs.writeScriptBin "poetry2nix-flamegraph" '' #!${pkgs.runtimeShell} export PATH=${runtimeDeps}:$PATH