Merge pull request #89126 from adisbladis/poetry2nix-1_9_0

poetry2nix: 1.8.0 -> 1.9.0
This commit is contained in:
adisbladis 2020-05-28 23:31:32 +02:00 committed by GitHub
commit c8e10792ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 965 additions and 868 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 // { pkgMeta // {
inherit pwd preferWheels; inherit pwd preferWheels;
source = pkgMeta.source or null; source = pkgMeta.source or null;
files = lockFiles.${name}; files = lockFiles.${name};
pythonPackages = self; pythonPackages = self;
sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name}; sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name} or { };
} }
); );
} }
) compatible )
compatible
); );
in in
lockPkgs; lockPkgs;
overlays = builtins.map getFunctorFn overlays = builtins.map
getFunctorFn
( (
[ [
( (
@ -127,6 +127,8 @@ let
}; };
/* Returns a package with a python interpreter and all packages specified in the poetry.lock lock file. /* Returns a package with a python interpreter and all packages specified in the poetry.lock lock file.
In editablePackageSources you can pass a mapping from package name to source directory to have
those packages available in the resulting environment, whose source changes are immediately available.
Example: Example:
poetry2nix.mkPoetryEnv { poetrylock = ./poetry.lock; python = python3; } poetry2nix.mkPoetryEnv { poetrylock = ./poetry.lock; python = python3; }
@ -139,18 +141,31 @@ let
, pwd ? projectDir , pwd ? projectDir
, python ? pkgs.python3 , python ? pkgs.python3
, preferWheels ? false , preferWheels ? false
# Example: { my-app = ./src; }
, editablePackageSources ? { }
}: }:
let let
py = mkPoetryPackages py = mkPoetryPackages (
(
{ {
inherit pyproject poetrylock overrides python pwd preferWheels; inherit pyproject poetrylock overrides python pwd preferWheels;
} }
); );
in
py.python.withPackages (_: py.poetryPackages);
/* Creates a Python application from pyproject.toml and poetry.lock */ editablePackage = import ./editable.nix {
inherit pkgs lib poetryLib editablePackageSources;
inherit (py) pyProject python;
};
in
py.python.withPackages (_: py.poetryPackages ++ lib.optional (editablePackageSources != { }) editablePackage);
/* Creates a Python application from pyproject.toml and poetry.lock
The result also contains a .dependencyEnv attribute which is a python
environment of all dependencies and this apps modules. This is useful if
you rely on dependencies to invoke your modules for deployment: e.g. this
allows `gunicorn my-module:app`.
*/
mkPoetryApplication = mkPoetryApplication =
{ projectDir ? null { projectDir ? null
, src ? poetryLib.cleanPythonSources { src = projectDir; } , src ? poetryLib.cleanPythonSources { src = projectDir; }
@ -194,17 +209,17 @@ 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;
}; };
in app = py.pkgs.buildPythonPackage (
py.pkgs.buildPythonApplication
(
passedAttrs // { passedAttrs // {
pname = moduleName pyProject.tool.poetry.name; pname = moduleName pyProject.tool.poetry.name;
version = pyProject.tool.poetry.version; version = pyProject.tool.poetry.version;
@ -212,6 +227,10 @@ let
inherit src; inherit src;
format = "pyproject"; format = "pyproject";
# Like buildPythonApplication, but without the toPythonModule part
# Meaning this ends up looking like an application but it also
# provides python modules
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 ]);
@ -220,16 +239,30 @@ let
passthru = { passthru = {
python = py; python = py;
dependencyEnv = (
lib.makeOverridable ({ app, ... }@attrs:
let
args = builtins.removeAttrs attrs [ "app" ] // {
extraLibs = [ app ];
};
in
py.buildEnv.override args)
) { inherit app; };
}; };
meta = meta // { meta = lib.optionalAttrs (lib.hasAttr "description" pyProject.tool.poetry) {
inherit (pyProject.tool.poetry) description homepage; inherit (pyProject.tool.poetry) description;
} // lib.optionalAttrs (lib.hasAttr "homepage" pyProject.tool.poetry) {
inherit (pyProject.tool.poetry) 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");
}; } // meta;
} }
); );
in
app;
/* Poetry2nix CLI used to supplement SHA-256 hashes for git dependencies */ /* Poetry2nix CLI used to supplement SHA-256 hashes for git dependencies */
cli = import ./cli.nix { inherit pkgs lib version; }; cli = import ./cli.nix { inherit pkgs lib version; };

View File

@ -0,0 +1,54 @@
{ pkgs
, lib
, poetryLib
, pyProject
, python
, editablePackageSources
}:
let
name = poetryLib.moduleName pyProject.tool.poetry.name;
# Just enough standard PKG-INFO fields for an editable installation
pkgInfoFields = {
Metadata-Version = "2.1";
Name = name;
# While the pyproject.toml could contain arbitrary version strings, for
# simplicity we just use the same one for PKG-INFO, even though that
# should follow follow PEP 440: https://www.python.org/dev/peps/pep-0345/#version
# This is how poetry transforms it: https://github.com/python-poetry/poetry/blob/6cd3645d889f47c10425961661b8193b23f0ed79/poetry/version/version.py
Version = pyProject.tool.poetry.version;
Summary = pyProject.tool.poetry.description;
};
pkgInfoFile = builtins.toFile "${name}-PKG-INFO"
(lib.concatStringsSep "\n" (lib.mapAttrsToList (key: value: "${key}: ${value}") pkgInfoFields));
entryPointsFile = builtins.toFile "${name}-entry_points.txt"
(lib.generators.toINI { } pyProject.tool.poetry.plugins);
# A python package that contains simple .egg-info and .pth files for an editable installation
editablePackage = python.pkgs.toPythonModule (pkgs.runCommandNoCC "${name}-editable"
{ } ''
mkdir -p "$out/${python.sitePackages}"
cd "$out/${python.sitePackages}"
# See https://docs.python.org/3.8/library/site.html for info on such .pth files
# These add another site package path for each line
touch poetry2nix-editable.pth
${lib.concatMapStringsSep "\n" (src: ''
echo "${toString src}" >> poetry2nix-editable.pth
'')
(lib.attrValues editablePackageSources)}
# Create a very simple egg so pkg_resources can find this package
# See https://setuptools.readthedocs.io/en/latest/formats.html for more info on the egg format
mkdir "${name}.egg-info"
cd "${name}.egg-info"
ln -s ${pkgInfoFile} PKG-INFO
${lib.optionalString (pyProject.tool.poetry ? plugins) ''
ln -s ${entryPointsFile} entry_points.txt
''}
''
);
in
editablePackage

View File

@ -14,7 +14,8 @@ in
removePathDependenciesHook = callPackage removePathDependenciesHook = callPackage
( (
{}: {}:
makeSetupHook { makeSetupHook
{
name = "remove-path-dependencies.sh"; name = "remove-path-dependencies.sh";
deps = [ ]; deps = [ ];
substitutions = { substitutions = {
@ -28,7 +29,8 @@ in
pipBuildHook = callPackage pipBuildHook = callPackage
( (
{ pip, wheel }: { pip, wheel }:
makeSetupHook { makeSetupHook
{
name = "pip-build-hook.sh"; name = "pip-build-hook.sh";
deps = [ pip wheel ]; deps = [ pip wheel ];
substitutions = { substitutions = {
@ -40,7 +42,8 @@ in
poetry2nixFixupHook = callPackage poetry2nixFixupHook = callPackage
( (
{}: {}:
makeSetupHook { makeSetupHook
{
name = "fixup-hook.sh"; name = "fixup-hook.sh";
deps = [ ]; deps = [ ];
} ./fixup-hook.sh } ./fixup-hook.sh

View File

@ -45,13 +45,12 @@ 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; inherit toml;
@ -88,8 +87,7 @@ 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}"
); );
@ -102,8 +100,7 @@ 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;
@ -143,8 +140,7 @@ 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

View File

@ -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

@ -6,16 +6,14 @@
self: super: self: super:
{ {
astroid = super.astroid.overridePythonAttrs astroid = super.astroid.overridePythonAttrs (
(
old: rec { old: rec {
buildInputs = old.buildInputs ++ [ self.pytest-runner ]; buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false; doCheck = false;
} }
); );
av = super.av.overridePythonAttrs av = super.av.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ nativeBuildInputs = old.nativeBuildInputs ++ [
pkgs.pkgconfig pkgs.pkgconfig
@ -24,8 +22,7 @@ self: super:
} }
); );
bcrypt = super.bcrypt.overridePythonAttrs bcrypt = super.bcrypt.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ pkgs.libffi ]; buildInputs = old.buildInputs ++ [ pkgs.libffi ];
} }
@ -34,16 +31,14 @@ self: super:
cffi = cffi =
# cffi is bundled with pypy # cffi is bundled with pypy
if self.python.implementation == "pypy" then null else ( if self.python.implementation == "pypy" then null else (
super.cffi.overridePythonAttrs super.cffi.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ pkgs.libffi ]; buildInputs = old.buildInputs ++ [ pkgs.libffi ];
} }
) )
); );
cftime = super.cftime.overridePythonAttrs cftime = super.cftime.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ buildInputs = old.buildInputs ++ [
self.cython self.cython
@ -51,8 +46,7 @@ self: super:
} }
); );
configparser = super.configparser.overridePythonAttrs configparser = super.configparser.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ buildInputs = old.buildInputs ++ [
self.toml self.toml
@ -64,16 +58,14 @@ self: super:
} }
); );
cryptography = super.cryptography.overridePythonAttrs cryptography = super.cryptography.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ pkgs.openssl ]; buildInputs = old.buildInputs ++ [ pkgs.openssl ];
} }
); );
django = ( django = (
super.django.overridePythonAttrs super.django.overridePythonAttrs (
(
old: { old: {
propagatedNativeBuildInputs = (old.propagatedNativeBuildInputs or [ ]) propagatedNativeBuildInputs = (old.propagatedNativeBuildInputs or [ ])
++ [ pkgs.gettext ]; ++ [ pkgs.gettext ];
@ -81,8 +73,7 @@ self: super:
) )
); );
django-bakery = super.django-bakery.overridePythonAttrs django-bakery = super.django-bakery.overridePythonAttrs (
(
old: { old: {
configurePhase = '' configurePhase = ''
if ! test -e LICENSE; then if ! test -e LICENSE; then
@ -92,8 +83,7 @@ self: super:
} }
); );
dlib = super.dlib.overridePythonAttrs dlib = super.dlib.overridePythonAttrs (
(
old: { old: {
# Parallel building enabled # Parallel building enabled
inherit (pkgs.python.pkgs.dlib) patches; inherit (pkgs.python.pkgs.dlib) patches;
@ -109,16 +99,14 @@ self: super:
# Environment markers are not always included (depending on how a dep was defined) # Environment markers are not always included (depending on how a dep was defined)
enum34 = if self.pythonAtLeast "3.4" then null else super.enum34; enum34 = if self.pythonAtLeast "3.4" then null else super.enum34;
faker = super.faker.overridePythonAttrs faker = super.faker.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ]; buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false; doCheck = false;
} }
); );
fancycompleter = super.fancycompleter.overridePythonAttrs fancycompleter = super.fancycompleter.overridePythonAttrs (
(
old: { old: {
postPatch = '' postPatch = ''
substituteInPlace setup.py \ substituteInPlace setup.py \
@ -128,23 +116,20 @@ self: super:
} }
); );
fastparquet = super.fastparquet.overridePythonAttrs fastparquet = super.fastparquet.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ]; buildInputs = old.buildInputs ++ [ self.pytest-runner ];
} }
); );
grandalf = super.grandalf.overridePythonAttrs grandalf = super.grandalf.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ]; buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false; doCheck = false;
} }
); );
h5py = super.h5py.overridePythonAttrs h5py = super.h5py.overridePythonAttrs (
(
old: old:
if old.format != "wheel" then rec { if old.format != "wheel" then rec {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
@ -156,30 +141,83 @@ self: super:
} else old } else old
); );
horovod = super.horovod.overridePythonAttrs horovod = super.horovod.overridePythonAttrs (
(
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.openmpi ]; propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.openmpi ];
} }
); );
imagecodecs = super.imagecodecs.overridePythonAttrs (
old: {
patchPhase = ''
substituteInPlace setup.py \
--replace "/usr/include/openjpeg-2.3" \
"${pkgs.openjpeg.dev}/include/openjpeg-2.3"
substituteInPlace setup.py \
--replace "/usr/include/jxrlib" \
"$out/include/libjxr"
substituteInPlace imagecodecs/_zopfli.c \
--replace '"zopfli/zopfli.h"' \
'<zopfli.h>'
substituteInPlace imagecodecs/_zopfli.c \
--replace '"zopfli/zlib_container.h"' \
'<zlib_container.h>'
substituteInPlace imagecodecs/_zopfli.c \
--replace '"zopfli/gzip_container.h"' \
'<gzip_container.h>'
'';
preBuild = ''
mkdir -p $out/include/libjxr
ln -s ${pkgs.jxrlib}/include/libjxr/**/* $out/include/libjxr
'';
buildInputs = old.buildInputs ++ [
# Commented out packages are declared required, but not actually
# needed to build. They are not yet packaged for nixpkgs.
# bitshuffle
pkgs.brotli
# brunsli
pkgs.bzip2
pkgs.c-blosc
# charls
pkgs.giflib
pkgs.jxrlib
pkgs.lcms
pkgs.libaec
pkgs.libaec
pkgs.libjpeg_turbo
# liblzf
# liblzma
pkgs.libpng
pkgs.libtiff
pkgs.libwebp
pkgs.lz4
pkgs.openjpeg
pkgs.snappy
# zfp
pkgs.zopfli
pkgs.zstd
pkgs.zlib
];
}
);
# importlib-metadata has an incomplete dependency specification # importlib-metadata has an incomplete dependency specification
importlib-metadata = super.importlib-metadata.overridePythonAttrs importlib-metadata = super.importlib-metadata.overridePythonAttrs (
(
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ lib.optional self.python.isPy2 self.pathlib2; propagatedBuildInputs = old.propagatedBuildInputs ++ lib.optional self.python.isPy2 self.pathlib2;
} }
); );
isort = super.isort.overridePythonAttrs isort = super.isort.overridePythonAttrs (
(
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.setuptools ]; propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.setuptools ];
} }
); );
jupyter = super.jupyter.overridePythonAttrs jupyter = super.jupyter.overridePythonAttrs (
(
old: rec { old: rec {
# jupyter is a meta-package. Everything relevant comes from the # jupyter is a meta-package. Everything relevant comes from the
# dependencies. It does however have a jupyter.py file that conflicts # dependencies. It does however have a jupyter.py file that conflicts
@ -188,8 +226,7 @@ self: super:
} }
); );
kiwisolver = super.kiwisolver.overridePythonAttrs kiwisolver = super.kiwisolver.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ buildInputs = old.buildInputs ++ [
# cppy is at the time of writing not in nixpkgs # cppy is at the time of writing not in nixpkgs
@ -198,8 +235,7 @@ self: super:
} }
); );
lap = super.lap.overridePythonAttrs lap = super.lap.overridePythonAttrs (
(
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = old.propagatedBuildInputs ++ [
self.numpy self.numpy
@ -207,8 +243,7 @@ self: super:
} }
); );
llvmlite = super.llvmlite.overridePythonAttrs llvmlite = super.llvmlite.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.llvm ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.llvm ];
@ -231,30 +266,26 @@ self: super:
} }
); );
lockfile = super.lockfile.overridePythonAttrs lockfile = super.lockfile.overridePythonAttrs (
(
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pbr ]; propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pbr ];
} }
); );
lxml = super.lxml.overridePythonAttrs lxml = super.lxml.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = with pkgs; old.nativeBuildInputs ++ [ pkgconfig libxml2.dev libxslt.dev ]; nativeBuildInputs = with pkgs; old.nativeBuildInputs ++ [ pkgconfig libxml2.dev libxslt.dev ];
buildInputs = with pkgs; old.buildInputs ++ [ libxml2 libxslt ]; buildInputs = with pkgs; old.buildInputs ++ [ libxml2 libxslt ];
} }
); );
markupsafe = super.markupsafe.overridePythonAttrs markupsafe = super.markupsafe.overridePythonAttrs (
(
old: { old: {
src = old.src.override { pname = builtins.replaceStrings [ "markupsafe" ] [ "MarkupSafe" ] old.pname; }; src = old.src.override { pname = builtins.replaceStrings [ "markupsafe" ] [ "MarkupSafe" ] old.pname; };
} }
); );
matplotlib = super.matplotlib.overridePythonAttrs matplotlib = super.matplotlib.overridePythonAttrs (
(
old: old:
let let
enableGhostscript = old.passthru.enableGhostscript or false; enableGhostscript = old.passthru.enableGhostscript or false;
@ -295,16 +326,14 @@ self: super:
preferWheel = true; preferWheel = true;
}; };
mccabe = super.mccabe.overridePythonAttrs mccabe = super.mccabe.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ]; buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false; doCheck = false;
} }
); );
netcdf4 = super.netcdf4.overridePythonAttrs netcdf4 = super.netcdf4.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ buildInputs = old.buildInputs ++ [
self.cython self.cython
@ -327,8 +356,7 @@ self: super:
} }
); );
numpy = super.numpy.overridePythonAttrs numpy = super.numpy.overridePythonAttrs (
(
old: old:
let let
blas = old.passthru.args.blas or pkgs.openblasCompat; blas = old.passthru.args.blas or pkgs.openblasCompat;
@ -336,7 +364,8 @@ self: super:
cfg = pkgs.writeTextFile { cfg = pkgs.writeTextFile {
name = "site.cfg"; name = "site.cfg";
text = ( text = (
lib.generators.toINI { } { lib.generators.toINI
{ } {
${blasImplementation} = { ${blasImplementation} = {
include_dirs = "${blas}/include"; include_dirs = "${blas}/include";
library_dirs = "${blas}/lib"; library_dirs = "${blas}/lib";
@ -362,16 +391,14 @@ self: super:
} }
); );
openexr = super.openexr.overridePythonAttrs openexr = super.openexr.overridePythonAttrs (
(
old: rec { old: rec {
buildInputs = old.buildInputs ++ [ pkgs.openexr pkgs.ilmbase ]; buildInputs = old.buildInputs ++ [ pkgs.openexr pkgs.ilmbase ];
NIX_CFLAGS_COMPILE = [ "-I${pkgs.openexr.dev}/include/OpenEXR" "-I${pkgs.ilmbase.dev}/include/OpenEXR" ]; NIX_CFLAGS_COMPILE = [ "-I${pkgs.openexr.dev}/include/OpenEXR" "-I${pkgs.ilmbase.dev}/include/OpenEXR" ];
} }
); );
peewee = super.peewee.overridePythonAttrs peewee = super.peewee.overridePythonAttrs (
(
old: old:
let let
withPostgres = old.passthru.withPostgres or false; withPostgres = old.passthru.withPostgres or false;
@ -385,31 +412,27 @@ self: super:
} }
); );
pillow = super.pillow.overridePythonAttrs pillow = super.pillow.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = [ pkgs.pkgconfig ] ++ old.nativeBuildInputs; nativeBuildInputs = [ pkgs.pkgconfig ] ++ old.nativeBuildInputs;
buildInputs = with pkgs; [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ] ++ old.buildInputs; buildInputs = with pkgs; [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ] ++ old.buildInputs;
} }
); );
psycopg2 = super.psycopg2.overridePythonAttrs psycopg2 = super.psycopg2.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ];
} }
); );
psycopg2-binary = super.psycopg2-binary.overridePythonAttrs psycopg2-binary = super.psycopg2-binary.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ];
} }
); );
pyarrow = pyarrow =
if lib.versionAtLeast super.pyarrow.version "0.16.0" then super.pyarrow.overridePythonAttrs if lib.versionAtLeast super.pyarrow.version "0.16.0" then super.pyarrow.overridePythonAttrs (
(
old: old:
let let
parseMinor = drv: lib.concatStringsSep "." (lib.take 2 (lib.splitVersion drv.version)); parseMinor = drv: lib.concatStringsSep "." (lib.take 2 (lib.splitVersion drv.version));
@ -450,8 +473,7 @@ self: super:
dontUseCmakeConfigure = true; dontUseCmakeConfigure = true;
} }
) else super.pyarrow.overridePythonAttrs ) else super.pyarrow.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ nativeBuildInputs = old.nativeBuildInputs ++ [
self.cython self.cython
@ -459,17 +481,14 @@ self: super:
} }
); );
pycairo = pycairo = (
(
drv: ( drv: (
drv.overridePythonAttrs drv.overridePythonAttrs (
(
_: { _: {
format = "other"; format = "other";
} }
) )
).overridePythonAttrs ).overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ nativeBuildInputs = old.nativeBuildInputs ++ [
@ -486,10 +505,10 @@ self: super:
mesonFlags = [ "-Dpython=${if self.isPy3k then "python3" else "python"}" ]; mesonFlags = [ "-Dpython=${if self.isPy3k then "python3" else "python"}" ];
} }
) )
) super.pycairo; )
super.pycairo;
pycocotools = super.pycocotools.overridePythonAttrs pycocotools = super.pycocotools.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ buildInputs = old.buildInputs ++ [
self.cython self.cython
@ -498,24 +517,21 @@ self: super:
} }
); );
pygobject = super.pygobject.overridePythonAttrs pygobject = super.pygobject.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
buildInputs = old.buildInputs ++ [ pkgs.glib pkgs.gobject-introspection ]; buildInputs = old.buildInputs ++ [ pkgs.glib pkgs.gobject-introspection ];
} }
); );
pylint = super.pylint.overridePythonAttrs pylint = super.pylint.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ]; buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false; doCheck = false;
} }
); );
pyopenssl = super.pyopenssl.overridePythonAttrs pyopenssl = super.pyopenssl.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ pkgs.openssl ]; buildInputs = old.buildInputs ++ [ pkgs.openssl ];
} }
@ -529,8 +545,7 @@ self: super:
withWebKit = drv.passthru.args.withWebKit or false; withWebKit = drv.passthru.args.withWebKit or false;
withWebSockets = drv.passthru.args.withWebSockets or false; withWebSockets = drv.passthru.args.withWebSockets or false;
in in
super.pyqt5.overridePythonAttrs super.pyqt5.overridePythonAttrs (
(
old: { old: {
format = "other"; format = "other";
@ -624,8 +639,7 @@ self: super:
} }
); );
pytest-datadir = super.pytest-datadir.overridePythonAttrs pytest-datadir = super.pytest-datadir.overridePythonAttrs (
(
old: { old: {
postInstall = '' postInstall = ''
rm -f $out/LICENSE rm -f $out/LICENSE
@ -633,8 +647,7 @@ self: super:
} }
); );
pytest = super.pytest.overridePythonAttrs pytest = super.pytest.overridePythonAttrs (
(
old: { old: {
doCheck = false; doCheck = false;
} }
@ -642,8 +655,7 @@ self: super:
pytest-runner = super.pytest-runner or super.pytestrunner; pytest-runner = super.pytest-runner or super.pytestrunner;
python-jose = super.python-jose.overridePythonAttrs python-jose = super.python-jose.overridePythonAttrs (
(
old: { old: {
postPath = '' postPath = ''
substituteInPlace setup.py --replace "'pytest-runner'," "" substituteInPlace setup.py --replace "'pytest-runner'," ""
@ -652,8 +664,7 @@ self: super:
} }
); );
python-prctl = super.python-prctl.overridePythonAttrs python-prctl = super.python-prctl.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ buildInputs = old.buildInputs ++ [
pkgs.libcap pkgs.libcap
@ -661,16 +672,14 @@ self: super:
} }
); );
pyzmq = super.pyzmq.overridePythonAttrs pyzmq = super.pyzmq.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.zeromq ]; propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.zeromq ];
} }
); );
rockset = super.rockset.overridePythonAttrs rockset = super.rockset.overridePythonAttrs (
(
old: rec { old: rec {
postPatch = '' postPatch = ''
cp ./setup_rockset.py ./setup.py cp ./setup_rockset.py ./setup.py
@ -678,8 +687,7 @@ self: super:
} }
); );
scaleapi = super.scaleapi.overridePythonAttrs scaleapi = super.scaleapi.overridePythonAttrs (
(
old: { old: {
postPatch = '' postPatch = ''
substituteInPlace setup.py --replace "install_requires = ['requests>=2.4.2', 'enum34']" "install_requires = ['requests>=2.4.2']" || true substituteInPlace setup.py --replace "install_requires = ['requests>=2.4.2', 'enum34']" "install_requires = ['requests>=2.4.2']" || true
@ -687,17 +695,21 @@ self: super:
} }
); );
pandas = super.pandas.overridePythonAttrs pandas = super.pandas.overridePythonAttrs (
(
old: { old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ self.cython ]; nativeBuildInputs = old.nativeBuildInputs ++ [ self.cython ];
} }
); );
panel = super.panel.overridePythonAttrs (
old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.nodejs ];
}
);
# Pybind11 is an undeclared dependency of scipy that we need to pick from nixpkgs # Pybind11 is an undeclared dependency of scipy that we need to pick from nixpkgs
# Make it not fail with infinite recursion # Make it not fail with infinite recursion
pybind11 = super.pybind11.overridePythonAttrs pybind11 = super.pybind11.overridePythonAttrs (
(
old: { old: {
cmakeFlags = (old.cmakeFlags or [ ]) ++ [ cmakeFlags = (old.cmakeFlags or [ ]) ++ [
"-DPYBIND11_TEST=off" "-DPYBIND11_TEST=off"
@ -706,8 +718,7 @@ self: super:
} }
); );
scipy = super.scipy.overridePythonAttrs scipy = super.scipy.overridePythonAttrs (
(
old: old:
if old.format != "wheel" then { if old.format != "wheel" then {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ];
@ -725,8 +736,7 @@ self: super:
} else old } else old
); );
scikit-learn = super.scikit-learn.overridePythonAttrs scikit-learn = super.scikit-learn.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ buildInputs = old.buildInputs ++ [
pkgs.gfortran pkgs.gfortran
@ -743,8 +753,7 @@ self: super:
} }
); );
shapely = super.shapely.overridePythonAttrs shapely = super.shapely.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ [ pkgs.geos self.cython ]; buildInputs = old.buildInputs ++ [ pkgs.geos self.cython ];
inherit (pkgs.python3.pkgs.shapely) patches GEOS_LIBRARY_PATH; inherit (pkgs.python3.pkgs.shapely) patches GEOS_LIBRARY_PATH;
@ -753,16 +762,14 @@ self: super:
shellingham = shellingham =
if lib.versionAtLeast super.shellingham.version "1.3.2" then ( if lib.versionAtLeast super.shellingham.version "1.3.2" then (
super.shellingham.overridePythonAttrs super.shellingham.overridePythonAttrs (
(
old: { old: {
format = "pyproject"; format = "pyproject";
} }
) )
) else super.shellingham; ) else super.shellingham;
tables = super.tables.overridePythonAttrs tables = super.tables.overridePythonAttrs (
(
old: { old: {
HDF5_DIR = "${pkgs.hdf5}"; HDF5_DIR = "${pkgs.hdf5}";
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ]; nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
@ -770,8 +777,7 @@ self: super:
} }
); );
tensorpack = super.tensorpack.overridePythonAttrs tensorpack = super.tensorpack.overridePythonAttrs (
(
old: { old: {
postPatch = '' postPatch = ''
substituteInPlace setup.cfg --replace "# will call find_packages()" "" substituteInPlace setup.cfg --replace "# will call find_packages()" ""
@ -779,8 +785,7 @@ self: super:
} }
); );
urwidtrees = super.urwidtrees.overridePythonAttrs urwidtrees = super.urwidtrees.overridePythonAttrs (
(
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = old.propagatedBuildInputs ++ [
self.urwid self.urwid
@ -788,8 +793,7 @@ self: super:
} }
); );
vose-alias-method = super.vose-alias-method.overridePythonAttrs vose-alias-method = super.vose-alias-method.overridePythonAttrs (
(
old: { old: {
postInstall = '' postInstall = ''
rm -f $out/LICENSE rm -f $out/LICENSE
@ -797,8 +801,7 @@ self: super:
} }
); );
uvloop = super.uvloop.overridePythonAttrs uvloop = super.uvloop.overridePythonAttrs (
(
old: { old: {
buildInputs = old.buildInputs ++ lib.optionals stdenv.isDarwin [ buildInputs = old.buildInputs ++ lib.optionals stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.ApplicationServices pkgs.darwin.apple_sdk.frameworks.ApplicationServices
@ -812,8 +815,7 @@ self: super:
pkgs.python3.pkgs.override { pkgs.python3.pkgs.override {
python = self.python; python = self.python;
} }
).wheel.overridePythonAttrs ).wheel.overridePythonAttrs (
(
old: old:
if old.format == "other" then old else { if old.format == "other" then old else {
inherit (super.wheel) pname name version src; inherit (super.wheel) pname name version src;
@ -823,8 +825,7 @@ self: super:
zipp = zipp =
( (
if lib.versionAtLeast super.zipp.version "2.0.0" then ( if lib.versionAtLeast super.zipp.version "2.0.0" then (
super.zipp.overridePythonAttrs super.zipp.overridePythonAttrs (
(
old: { old: {
prePatch = '' prePatch = ''
substituteInPlace setup.py --replace \ substituteInPlace setup.py --replace \
@ -834,8 +835,7 @@ self: super:
} }
) )
) else super.zipp ) else super.zipp
).overridePythonAttrs ).overridePythonAttrs (
(
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = old.propagatedBuildInputs ++ [
self.toml self.toml

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'
findSubExpressionsFun
{
exprs = [ ]; exprs = [ ];
expr = expr; expr = expr;
pos = 0; pos = 0;
openP = 0; openP = 0;
exprPos = 0; exprPos = 0;
startPos = 0; startPos = 0;
} (lib.stringToCharacters expr); }
(lib.stringToCharacters expr);
tailExpr = (substr acc.exprPos acc.pos expr); tailExpr = (substr acc.exprPos acc.pos expr);
tailExprs = if tailExpr != "" then [ tailExpr ] else [ ]; tailExprs = if tailExpr != "" then [ tailExpr ] else [ ];
in in
@ -72,7 +75,8 @@ let
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,8 +163,7 @@ 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);
@ -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'
reduceExpressionsFun
{
value = true; value = true;
cond = "and"; cond = "and";
} v; }
v;
in in
acc // { acc // {
value = cond."${acc.cond}" acc.value ret.value; value = cond."${acc.cond}" acc.value ret.value;
@ -219,10 +225,13 @@ let
); );
in in
( (
builtins.foldl' reduceExpressionsFun { builtins.foldl'
reduceExpressionsFun
{
value = true; value = true;
cond = "and"; cond = "and";
} exprs }
exprs
).value; ).value;
in in
e: builtins.foldl' (acc: v: v acc) e [ e: builtins.foldl' (acc: v: v acc) e [

View File

@ -39,8 +39,7 @@ 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);
@ -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; }