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:
let
getDep = depName: self.${depName};
lockPkgs = builtins.listToAttrs
(
lockPkgs = builtins.listToAttrs (
builtins.map
(
pkgMeta: rec {
name = moduleName pkgMeta.name;
value = self.mkPoetryDep
(
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};
sourceSpec = pyProject.tool.poetry.dependencies.${name} or pyProject.tool.poetry.dev-dependencies.${name} or { };
}
);
}
) compatible
)
compatible
);
in
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.
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:
poetry2nix.mkPoetryEnv { poetrylock = ./poetry.lock; python = python3; }
@ -139,18 +141,31 @@ let
, pwd ? projectDir
, python ? pkgs.python3
, preferWheels ? false
# Example: { my-app = ./src; }
, editablePackageSources ? { }
}:
let
py = mkPoetryPackages
(
py = mkPoetryPackages (
{
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 =
{ projectDir ? null
, src ? poetryLib.cleanPythonSources { src = projectDir; }
@ -194,17 +209,17 @@ let
pkg = py.pkgs."${dep}";
constraints = deps.${dep}.python or "";
isCompat = compat constraints;
in if isCompat then pkg else null
) depAttrs;
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
(
app = py.pkgs.buildPythonPackage (
passedAttrs // {
pname = moduleName pyProject.tool.poetry.name;
version = pyProject.tool.poetry.version;
@ -212,6 +227,10 @@ let
inherit src;
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;
propagatedBuildInputs = mkInput "propagatedBuildInputs" (getDeps "dependencies") ++ ([ py.pkgs.setuptools ]);
@ -220,16 +239,30 @@ let
passthru = {
python = py;
dependencyEnv = (
lib.makeOverridable ({ app, ... }@attrs:
let
args = builtins.removeAttrs attrs [ "app" ] // {
extraLibs = [ app ];
};
in
py.buildEnv.override args)
) { inherit app; };
};
meta = meta // {
inherit (pyProject.tool.poetry) description homepage;
meta = lib.optionalAttrs (lib.hasAttr "description" pyProject.tool.poetry) {
inherit (pyProject.tool.poetry) description;
} // lib.optionalAttrs (lib.hasAttr "homepage" pyProject.tool.poetry) {
inherit (pyProject.tool.poetry) homepage;
} // {
inherit (py.meta) platforms;
license = getLicenseBySpdxId (pyProject.tool.poetry.license or "unknown");
};
} // meta;
}
);
in
app;
/* Poetry2nix CLI used to supplement SHA-256 hashes for git dependencies */
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
(
{}:
makeSetupHook {
makeSetupHook
{
name = "remove-path-dependencies.sh";
deps = [ ];
substitutions = {
@ -28,7 +29,8 @@ in
pipBuildHook = callPackage
(
{ pip, wheel }:
makeSetupHook {
makeSetupHook
{
name = "pip-build-hook.sh";
deps = [ pip wheel ];
substitutions = {
@ -40,7 +42,8 @@ in
poetry2nixFixupHook = callPackage
(
{}:
makeSetupHook {
makeSetupHook
{
name = "fixup-hook.sh";
deps = [ ];
} ./fixup-hook.sh

View File

@ -45,13 +45,12 @@ let
state = operators."${operator}" acc.state (satisfiesSemver version v);
};
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
(
toml: builtins.fromJSON
(
builtins.readFile
(
toml: builtins.fromJSON (
builtins.readFile (
pkgs.runCommand "from-toml"
{
inherit toml;
@ -88,8 +87,7 @@ let
# file: filename including extension
# hash: SRI hash
# kind: Language implementation and version tag
predictURLFromPypi = lib.makeOverridable
(
predictURLFromPypi = lib.makeOverridable (
{ pname, file, hash, kind }:
"https://files.pythonhosted.org/packages/${kind}/${lib.toLower (builtins.substring 0 1 file)}/${pname}/${file}"
);
@ -102,8 +100,7 @@ let
# file: filename including extension
# hash: SRI hash
# kind: Language implementation and version tag
fetchWheelFromPypi = lib.makeOverridable
(
fetchWheelFromPypi = lib.makeOverridable (
{ pname, file, hash, kind, curlOpts ? "" }:
let
version = builtins.elemAt (builtins.split "-" file) 2;
@ -143,8 +140,7 @@ 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
(
fetchFromPypi = lib.makeOverridable (
{ pname, file, hash, kind }:
if lib.strings.hasSuffix "whl" file then fetchWheelFromPypi { inherit pname file hash kind; }
else

View File

@ -111,7 +111,8 @@ pythonPackages.callPackage
propagatedBuildInputs =
let
compat = isCompatible (poetryLib.getPythonVersion python);
deps = lib.filterAttrs (n: v: v)
deps = lib.filterAttrs
(n: v: v)
(
lib.mapAttrs
(
@ -120,7 +121,8 @@ pythonPackages.callPackage
constraints = v.python or "";
in
compat constraints
) dependencies
)
dependencies
);
depAttrs = lib.attrNames deps;
in

View File

@ -6,16 +6,14 @@
self: super:
{
astroid = super.astroid.overridePythonAttrs
(
astroid = super.astroid.overridePythonAttrs (
old: rec {
buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false;
}
);
av = super.av.overridePythonAttrs
(
av = super.av.overridePythonAttrs (
old: {
nativeBuildInputs = old.nativeBuildInputs ++ [
pkgs.pkgconfig
@ -24,8 +22,7 @@ self: super:
}
);
bcrypt = super.bcrypt.overridePythonAttrs
(
bcrypt = super.bcrypt.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ pkgs.libffi ];
}
@ -34,16 +31,14 @@ self: super:
cffi =
# cffi is bundled with pypy
if self.python.implementation == "pypy" then null else (
super.cffi.overridePythonAttrs
(
super.cffi.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ pkgs.libffi ];
}
)
);
cftime = super.cftime.overridePythonAttrs
(
cftime = super.cftime.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [
self.cython
@ -51,8 +46,7 @@ self: super:
}
);
configparser = super.configparser.overridePythonAttrs
(
configparser = super.configparser.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [
self.toml
@ -64,16 +58,14 @@ self: super:
}
);
cryptography = super.cryptography.overridePythonAttrs
(
cryptography = super.cryptography.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ pkgs.openssl ];
}
);
django = (
super.django.overridePythonAttrs
(
super.django.overridePythonAttrs (
old: {
propagatedNativeBuildInputs = (old.propagatedNativeBuildInputs or [ ])
++ [ pkgs.gettext ];
@ -81,8 +73,7 @@ self: super:
)
);
django-bakery = super.django-bakery.overridePythonAttrs
(
django-bakery = super.django-bakery.overridePythonAttrs (
old: {
configurePhase = ''
if ! test -e LICENSE; then
@ -92,8 +83,7 @@ self: super:
}
);
dlib = super.dlib.overridePythonAttrs
(
dlib = super.dlib.overridePythonAttrs (
old: {
# Parallel building enabled
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)
enum34 = if self.pythonAtLeast "3.4" then null else super.enum34;
faker = super.faker.overridePythonAttrs
(
faker = super.faker.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false;
}
);
fancycompleter = super.fancycompleter.overridePythonAttrs
(
fancycompleter = super.fancycompleter.overridePythonAttrs (
old: {
postPatch = ''
substituteInPlace setup.py \
@ -128,23 +116,20 @@ self: super:
}
);
fastparquet = super.fastparquet.overridePythonAttrs
(
fastparquet = super.fastparquet.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ];
}
);
grandalf = super.grandalf.overridePythonAttrs
(
grandalf = super.grandalf.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false;
}
);
h5py = super.h5py.overridePythonAttrs
(
h5py = super.h5py.overridePythonAttrs (
old:
if old.format != "wheel" then rec {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
@ -156,30 +141,83 @@ self: super:
} else old
);
horovod = super.horovod.overridePythonAttrs
(
horovod = super.horovod.overridePythonAttrs (
old: {
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 = super.importlib-metadata.overridePythonAttrs
(
importlib-metadata = super.importlib-metadata.overridePythonAttrs (
old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ lib.optional self.python.isPy2 self.pathlib2;
}
);
isort = super.isort.overridePythonAttrs
(
isort = super.isort.overridePythonAttrs (
old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.setuptools ];
}
);
jupyter = super.jupyter.overridePythonAttrs
(
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
@ -188,8 +226,7 @@ self: super:
}
);
kiwisolver = super.kiwisolver.overridePythonAttrs
(
kiwisolver = super.kiwisolver.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [
# 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: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [
self.numpy
@ -207,8 +243,7 @@ self: super:
}
);
llvmlite = super.llvmlite.overridePythonAttrs
(
llvmlite = super.llvmlite.overridePythonAttrs (
old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.llvm ];
@ -231,30 +266,26 @@ self: super:
}
);
lockfile = super.lockfile.overridePythonAttrs
(
lockfile = super.lockfile.overridePythonAttrs (
old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pbr ];
}
);
lxml = super.lxml.overridePythonAttrs
(
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
(
markupsafe = super.markupsafe.overridePythonAttrs (
old: {
src = old.src.override { pname = builtins.replaceStrings [ "markupsafe" ] [ "MarkupSafe" ] old.pname; };
}
);
matplotlib = super.matplotlib.overridePythonAttrs
(
matplotlib = super.matplotlib.overridePythonAttrs (
old:
let
enableGhostscript = old.passthru.enableGhostscript or false;
@ -295,16 +326,14 @@ self: super:
preferWheel = true;
};
mccabe = super.mccabe.overridePythonAttrs
(
mccabe = super.mccabe.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false;
}
);
netcdf4 = super.netcdf4.overridePythonAttrs
(
netcdf4 = super.netcdf4.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [
self.cython
@ -327,8 +356,7 @@ self: super:
}
);
numpy = super.numpy.overridePythonAttrs
(
numpy = super.numpy.overridePythonAttrs (
old:
let
blas = old.passthru.args.blas or pkgs.openblasCompat;
@ -336,7 +364,8 @@ self: super:
cfg = pkgs.writeTextFile {
name = "site.cfg";
text = (
lib.generators.toINI { } {
lib.generators.toINI
{ } {
${blasImplementation} = {
include_dirs = "${blas}/include";
library_dirs = "${blas}/lib";
@ -362,16 +391,14 @@ self: super:
}
);
openexr = super.openexr.overridePythonAttrs
(
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
(
peewee = super.peewee.overridePythonAttrs (
old:
let
withPostgres = old.passthru.withPostgres or false;
@ -385,31 +412,27 @@ self: super:
}
);
pillow = super.pillow.overridePythonAttrs
(
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
(
psycopg2 = super.psycopg2.overridePythonAttrs (
old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.postgresql ];
}
);
psycopg2-binary = super.psycopg2-binary.overridePythonAttrs
(
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
(
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));
@ -450,8 +473,7 @@ self: super:
dontUseCmakeConfigure = true;
}
) else super.pyarrow.overridePythonAttrs
(
) else super.pyarrow.overridePythonAttrs (
old: {
nativeBuildInputs = old.nativeBuildInputs ++ [
self.cython
@ -459,17 +481,14 @@ self: super:
}
);
pycairo =
(
pycairo = (
drv: (
drv.overridePythonAttrs
(
drv.overridePythonAttrs (
_: {
format = "other";
}
)
).overridePythonAttrs
(
).overridePythonAttrs (
old: {
nativeBuildInputs = old.nativeBuildInputs ++ [
@ -486,10 +505,10 @@ self: super:
mesonFlags = [ "-Dpython=${if self.isPy3k then "python3" else "python"}" ];
}
)
) super.pycairo;
)
super.pycairo;
pycocotools = super.pycocotools.overridePythonAttrs
(
pycocotools = super.pycocotools.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [
self.cython
@ -498,24 +517,21 @@ self: super:
}
);
pygobject = super.pygobject.overridePythonAttrs
(
pygobject = super.pygobject.overridePythonAttrs (
old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
buildInputs = old.buildInputs ++ [ pkgs.glib pkgs.gobject-introspection ];
}
);
pylint = super.pylint.overridePythonAttrs
(
pylint = super.pylint.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ self.pytest-runner ];
doCheck = false;
}
);
pyopenssl = super.pyopenssl.overridePythonAttrs
(
pyopenssl = super.pyopenssl.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ pkgs.openssl ];
}
@ -529,8 +545,7 @@ self: super:
withWebKit = drv.passthru.args.withWebKit or false;
withWebSockets = drv.passthru.args.withWebSockets or false;
in
super.pyqt5.overridePythonAttrs
(
super.pyqt5.overridePythonAttrs (
old: {
format = "other";
@ -624,8 +639,7 @@ self: super:
}
);
pytest-datadir = super.pytest-datadir.overridePythonAttrs
(
pytest-datadir = super.pytest-datadir.overridePythonAttrs (
old: {
postInstall = ''
rm -f $out/LICENSE
@ -633,8 +647,7 @@ self: super:
}
);
pytest = super.pytest.overridePythonAttrs
(
pytest = super.pytest.overridePythonAttrs (
old: {
doCheck = false;
}
@ -642,8 +655,7 @@ self: super:
pytest-runner = super.pytest-runner or super.pytestrunner;
python-jose = super.python-jose.overridePythonAttrs
(
python-jose = super.python-jose.overridePythonAttrs (
old: {
postPath = ''
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: {
buildInputs = old.buildInputs ++ [
pkgs.libcap
@ -661,16 +672,14 @@ self: super:
}
);
pyzmq = super.pyzmq.overridePythonAttrs
(
pyzmq = super.pyzmq.overridePythonAttrs (
old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.zeromq ];
}
);
rockset = super.rockset.overridePythonAttrs
(
rockset = super.rockset.overridePythonAttrs (
old: rec {
postPatch = ''
cp ./setup_rockset.py ./setup.py
@ -678,8 +687,7 @@ self: super:
}
);
scaleapi = super.scaleapi.overridePythonAttrs
(
scaleapi = super.scaleapi.overridePythonAttrs (
old: {
postPatch = ''
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: {
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
# Make it not fail with infinite recursion
pybind11 = super.pybind11.overridePythonAttrs
(
pybind11 = super.pybind11.overridePythonAttrs (
old: {
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
"-DPYBIND11_TEST=off"
@ -706,8 +718,7 @@ self: super:
}
);
scipy = super.scipy.overridePythonAttrs
(
scipy = super.scipy.overridePythonAttrs (
old:
if old.format != "wheel" then {
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.gfortran ];
@ -725,8 +736,7 @@ self: super:
} else old
);
scikit-learn = super.scikit-learn.overridePythonAttrs
(
scikit-learn = super.scikit-learn.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [
pkgs.gfortran
@ -743,8 +753,7 @@ self: super:
}
);
shapely = super.shapely.overridePythonAttrs
(
shapely = super.shapely.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ pkgs.geos self.cython ];
inherit (pkgs.python3.pkgs.shapely) patches GEOS_LIBRARY_PATH;
@ -753,16 +762,14 @@ self: super:
shellingham =
if lib.versionAtLeast super.shellingham.version "1.3.2" then (
super.shellingham.overridePythonAttrs
(
super.shellingham.overridePythonAttrs (
old: {
format = "pyproject";
}
)
) else super.shellingham;
tables = super.tables.overridePythonAttrs
(
tables = super.tables.overridePythonAttrs (
old: {
HDF5_DIR = "${pkgs.hdf5}";
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.pkgconfig ];
@ -770,8 +777,7 @@ self: super:
}
);
tensorpack = super.tensorpack.overridePythonAttrs
(
tensorpack = super.tensorpack.overridePythonAttrs (
old: {
postPatch = ''
substituteInPlace setup.cfg --replace "# will call find_packages()" ""
@ -779,8 +785,7 @@ self: super:
}
);
urwidtrees = super.urwidtrees.overridePythonAttrs
(
urwidtrees = super.urwidtrees.overridePythonAttrs (
old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [
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: {
postInstall = ''
rm -f $out/LICENSE
@ -797,8 +801,7 @@ self: super:
}
);
uvloop = super.uvloop.overridePythonAttrs
(
uvloop = super.uvloop.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ lib.optionals stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.ApplicationServices
@ -812,8 +815,7 @@ self: super:
pkgs.python3.pkgs.override {
python = self.python;
}
).wheel.overridePythonAttrs
(
).wheel.overridePythonAttrs (
old:
if old.format == "other" then old else {
inherit (super.wheel) pname name version src;
@ -823,8 +825,7 @@ self: super:
zipp =
(
if lib.versionAtLeast super.zipp.version "2.0.0" then (
super.zipp.overridePythonAttrs
(
super.zipp.overridePythonAttrs (
old: {
prePatch = ''
substituteInPlace setup.py --replace \
@ -834,8 +835,7 @@ self: super:
}
)
) else super.zipp
).overridePythonAttrs
(
).overridePythonAttrs (
old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [
self.toml

View File

@ -37,14 +37,17 @@ let
# Make a tree out of expression groups (parens)
findSubExpressions = expr:
let
acc = builtins.foldl' findSubExpressionsFun {
acc = builtins.foldl'
findSubExpressionsFun
{
exprs = [ ];
expr = expr;
pos = 0;
openP = 0;
exprPos = 0;
startPos = 0;
} (lib.stringToCharacters expr);
}
(lib.stringToCharacters expr);
tailExpr = (substr acc.exprPos acc.pos expr);
tailExprs = if tailExpr != "" then [ tailExpr ] else [ ];
in
@ -72,7 +75,8 @@ let
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
@ -159,8 +163,7 @@ let
let
parts = builtins.splitVersion c;
pruned = lib.take ((builtins.length parts) - 1) parts;
upper = builtins.toString
(
upper = builtins.toString (
(lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1
);
upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned);
@ -207,10 +210,13 @@ let
) else throw "Unsupported type"
) else if builtins.typeOf v == "list" then (
let
ret = builtins.foldl' reduceExpressionsFun {
ret = builtins.foldl'
reduceExpressionsFun
{
value = true;
cond = "and";
} v;
}
v;
in
acc // {
value = cond."${acc.cond}" acc.value ret.value;
@ -219,10 +225,13 @@ let
);
in
(
builtins.foldl' reduceExpressionsFun {
builtins.foldl'
reduceExpressionsFun
{
value = true;
cond = "and";
} exprs
}
exprs
).value;
in
e: builtins.foldl' (acc: v: v acc) e [

View File

@ -39,8 +39,7 @@ let
# Prune constraint
parts = builtins.splitVersion c;
pruned = lib.take ((builtins.length parts) - 1) parts;
upper = builtins.toString
(
upper = builtins.toString (
(lib.toInt (builtins.elemAt pruned (builtins.length pruned - 1))) + 1
);
upperConstraint = builtins.concatStringsSep "." (ireplace (builtins.length pruned - 1) upper pruned);
@ -82,6 +81,7 @@ let
satisfiesSemver = version: constraint:
let
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
{ inherit satisfiesSemver; }