poetry2nix: 1.16.1 -> 1.17.0

This commit is contained in:
adisbladis 2021-06-01 16:59:39 -05:00
parent b6e6f1dddd
commit 43d59e94dc
No known key found for this signature in database
GPG Key ID: 110BFAD44C6249B7
7 changed files with 376 additions and 61 deletions

View File

@ -5,7 +5,7 @@
}: }:
let let
# Poetry2nix version # Poetry2nix version
version = "1.16.1"; version = "1.17.0";
inherit (poetryLib) isCompatible readTOML moduleName; inherit (poetryLib) isCompatible readTOML moduleName;
@ -163,7 +163,7 @@ lib.makeScope pkgs.newScope (self: {
compatible = partitions.right; compatible = partitions.right;
incompatible = partitions.wrong; incompatible = partitions.wrong;
# Create an overriden version of pythonPackages # Create an overridden version of pythonPackages
# #
# We need to avoid mixing multiple versions of pythonPackages in the same # We need to avoid mixing multiple versions of pythonPackages in the same
# closure as python can only ever have one version of a dependency # closure as python can only ever have one version of a dependency
@ -229,7 +229,12 @@ lib.makeScope pkgs.newScope (self: {
inputAttrs = mkInputAttrs { inherit py pyProject; attrs = { }; includeBuildSystem = false; }; inputAttrs = mkInputAttrs { inherit py pyProject; attrs = { }; includeBuildSystem = false; };
storePackages = builtins.foldl' (acc: v: acc ++ v) [ ] (lib.attrValues inputAttrs); requiredPythonModules = python.pkgs.requiredPythonModules;
/* Include all the nested dependencies which are required for each package.
This guarantees that using the "poetryPackages" attribute will return
complete list of dependencies for the poetry project to be portable.
*/
storePackages = requiredPythonModules (builtins.foldl' (acc: v: acc ++ v) [ ] (lib.attrValues inputAttrs));
in in
{ {
python = py; python = py;

View File

@ -9,12 +9,12 @@ curl="curl \
--cookie-jar cookies \ --cookie-jar cookies \
--insecure \ --insecure \
--speed-time 5 \ --speed-time 5 \
-# \ --progress-bar \
--fail \ --fail \
$curlOpts \ $curlOpts \
$NIX_CURL_FLAGS" $NIX_CURL_FLAGS"
echo "Trying to fetch wheel with predicted URL: $predictedURL" echo "Trying to fetch with predicted URL: $predictedURL"
$curl $predictedURL --output $out && exit 0 $curl $predictedURL --output $out && exit 0

View File

@ -0,0 +1,72 @@
# Some repositories (such as Devpi) expose the Pypi legacy API
# (https://warehouse.pypa.io/api-reference/legacy.html).
#
# Note it is not possible to use pip
# https://discuss.python.org/t/pip-download-just-the-source-packages-no-building-no-metadata-etc/4651/12
import sys
from urllib.parse import urlparse
from html.parser import HTMLParser
import urllib.request
import shutil
import ssl
import os
# Parse the legacy index page to extract the href and package names
class Pep503(HTMLParser):
def __init__(self):
super().__init__()
self.sources = {}
self.url = None
self.name = None
def handle_data(self, data):
if self.url is not None:
self.name = data
def handle_starttag(self, tag, attrs):
if tag == "a":
for name, value in attrs:
if name == "href":
self.url = value
def handle_endtag(self, tag):
if self.url is not None:
self.sources[self.name] = self.url
self.url = None
url = sys.argv[1]
package_name = sys.argv[2]
index_url = url + "/" + package_name
package_filename = sys.argv[3]
print("Reading index %s" % index_url)
response = urllib.request.urlopen(
index_url,
context=ssl.CERT_NONE)
index = response.read()
parser = Pep503()
parser.feed(str(index))
if package_filename not in parser.sources:
print("The file %s has not be found in the index %s" % (
package_filename, index_url))
exit(1)
package_file = open(package_filename, "wb")
# Sometimes the href is a relative path
if urlparse(parser.sources[package_filename]).netloc == '':
package_url = index_url + "/" + parser.sources[package_filename]
else:
package_url = parser.sources[package_filename]
print("Downloading %s" % package_url)
response = urllib.request.urlopen(
package_url,
context=ssl.CERT_NONE)
with response as r:
shutil.copyfileobj(r, package_file)

View File

@ -93,17 +93,19 @@ let
); );
# Fetch the wheels from the PyPI index. # Fetch from the PyPI index.
# We need to first get the proper URL to the wheel. # At first we try to fetch the predicated URL but if that fails we
# will use the Pypi API to determine the correct URL.
# Args: # Args:
# pname: package name # pname: package name
# file: filename including extension # file: filename including extension
# version: the version string of the dependency
# hash: SRI hash # hash: SRI hash
# kind: Language implementation and version tag # kind: Language implementation and version tag
fetchWheelFromPypi = lib.makeOverridable ( fetchFromPypi = lib.makeOverridable (
{ pname, file, hash, kind, curlOpts ? "" }: { pname, file, version, hash, kind, curlOpts ? "" }:
let let
version = builtins.elemAt (builtins.split "-" file) 2; predictedURL = predictURLFromPypi { inherit pname file hash kind; };
in in
(pkgs.stdenvNoCC.mkDerivation { (pkgs.stdenvNoCC.mkDerivation {
name = file; name = file;
@ -111,7 +113,7 @@ let
pkgs.curl pkgs.curl
pkgs.jq pkgs.jq
]; ];
isWheel = true; isWheel = lib.strings.hasSuffix "whl" file;
system = "builtin"; system = "builtin";
preferLocalBuild = true; preferLocalBuild = true;
@ -119,36 +121,35 @@ let
"NIX_CURL_FLAGS" "NIX_CURL_FLAGS"
]; ];
predictedURL = predictURLFromPypi { inherit pname file hash kind; }; inherit pname file version curlOpts predictedURL;
inherit pname file version curlOpts;
builder = ./fetch-wheel.sh; builder = ./fetch-from-pypi.sh;
outputHashMode = "flat"; outputHashMode = "flat";
outputHashAlgo = "sha256"; outputHashAlgo = "sha256";
outputHash = hash; outputHash = hash;
passthru = {
urls = [ predictedURL ]; # retain compatibility with nixpkgs' fetchurl
};
}) })
); );
# Fetch the artifacts from the PyPI index. Since we get all fetchFromLegacy = lib.makeOverridable (
# info we need from the lock file we don't use nixpkgs' fetchPyPi { python, pname, url, file, hash }:
# as it modifies casing while not providing anything we don't already pkgs.runCommand file
# have. {
# nativeBuildInputs = [ python ];
# Args: impureEnvVars = lib.fetchers.proxyImpureEnvVars;
# pname: package name outputHashMode = "flat";
# file: filename including extension outputHashAlgo = "sha256";
# hash: SRI hash outputHash = hash;
# kind: Language implementation and version tag https://www.python.org/dev/peps/pep-0427/#file-name-convention } ''
fetchFromPypi = lib.makeOverridable ( python ${./fetch_from_legacy.py} ${url} ${pname} ${file}
{ pname, file, hash, kind }: mv ${file} $out
if lib.strings.hasSuffix "whl" file then fetchWheelFromPypi { inherit pname file hash kind; } ''
else
pkgs.fetchurl {
url = predictURLFromPypi { inherit pname file hash kind; };
inherit hash;
}
); );
getBuildSystemPkgs = getBuildSystemPkgs =
{ pythonPackages { pythonPackages
, pyProject , pyProject
@ -215,7 +216,7 @@ in
{ {
inherit inherit
fetchFromPypi fetchFromPypi
fetchWheelFromPypi fetchFromLegacy
getManyLinuxDeps getManyLinuxDeps
isCompatible isCompatible
readTOML readTOML

View File

@ -28,7 +28,7 @@ pythonPackages.callPackage
}@args: }@args:
let let
inherit (pkgs) stdenv; inherit (pkgs) stdenv;
inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromPypi moduleName; inherit (poetryLib) isCompatible getManyLinuxDeps fetchFromLegacy fetchFromPypi moduleName;
inherit (import ./pep425.nix { inherit (import ./pep425.nix {
inherit lib poetryLib python; inherit lib poetryLib python;
@ -37,7 +37,7 @@ pythonPackages.callPackage
; ;
fileCandidates = fileCandidates =
let let
supportedRegex = ("^.*?(" + builtins.concatStringsSep "|" supportedExtensions + ")"); supportedRegex = ("^.*(" + builtins.concatStringsSep "|" supportedExtensions + ")");
matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null; matchesVersion = fname: builtins.match ("^.*" + builtins.replaceStrings [ "." ] [ "\\." ] version + ".*$") fname != null;
hasSupportedExtension = fname: builtins.match supportedRegex fname != null; hasSupportedExtension = fname: builtins.match supportedRegex fname != null;
isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname; isCompatibleEgg = fname: ! lib.strings.hasSuffix ".egg" fname || lib.strings.hasSuffix "py${python.pythonVersion}.egg" fname;
@ -48,6 +48,7 @@ pythonPackages.callPackage
isGit = isSource && source.type == "git"; isGit = isSource && source.type == "git";
isUrl = isSource && source.type == "url"; isUrl = isSource && source.type == "url";
isLocal = isSource && source.type == "directory"; isLocal = isSource && source.type == "directory";
isLegacy = isSource && source.type == "legacy";
localDepPath = toPath source.url; localDepPath = toPath source.url;
buildSystemPkgs = buildSystemPkgs =
@ -171,10 +172,19 @@ pythonPackages.callPackage
} }
else if isLocal then else if isLocal then
(poetryLib.cleanPythonSources { src = localDepPath; }) (poetryLib.cleanPythonSources { src = localDepPath; })
else if isLegacy then
fetchFromLegacy
{
pname = name;
inherit python;
inherit (fileInfo) file hash;
inherit (source) url;
}
else else
fetchFromPypi { fetchFromPypi {
pname = name; pname = name;
inherit (fileInfo) file hash kind; inherit (fileInfo) file hash kind;
inherit version;
}; };
} }
) )

View File

@ -8,7 +8,13 @@ self: super:
{ {
automat = super.automat.overridePythonAttrs ( automat = super.automat.overridePythonAttrs (
old: rec { old: rec {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.m2r ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.m2r ];
}
);
aiohttp-swagger3 = super.aiohttp-swagger3.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pytest-runner ];
} }
); );
@ -21,7 +27,7 @@ self: super:
# Inputs copied from nixpkgs as ansible doesn't specify it's dependencies # Inputs copied from nixpkgs as ansible doesn't specify it's dependencies
# in a correct manner. # in a correct manner.
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
self.pycrypto self.pycrypto
self.paramiko self.paramiko
self.jinja2 self.jinja2
@ -170,7 +176,7 @@ self: super:
dictdiffer = super.dictdiffer.overridePythonAttrs ( dictdiffer = super.dictdiffer.overridePythonAttrs (
old: { old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ]; buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.setuptools ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.setuptools ];
} }
); );
@ -178,7 +184,7 @@ self: super:
super.django.overridePythonAttrs ( super.django.overridePythonAttrs (
old: { old: {
propagatedNativeBuildInputs = (old.propagatedNativeBuildInputs or [ ]) propagatedNativeBuildInputs = (old.propagatedNativeBuildInputs or [ ])
++ [ pkgs.gettext ]; ++ [ pkgs.gettext self.pytest-runner ];
} }
) )
); );
@ -193,6 +199,36 @@ self: super:
} }
); );
django-cors-headers = super.django-cors-headers.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pytest-runner ];
}
);
django-hijack = super.django-hijack.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pytest-runner ];
}
);
django-prometheus = super.django-prometheus.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pytest-runner ];
}
);
django-rosetta = super.django-rosetta.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pytest-runner ];
}
);
django-stubs-ext = super.django-stubs-ext.overridePythonAttrs (
old: {
prePatch = (old.prePatch or "") + "touch ../LICENSE.txt";
}
);
dlib = super.dlib.overridePythonAttrs ( dlib = super.dlib.overridePythonAttrs (
old: { old: {
# Parallel building enabled # Parallel building enabled
@ -227,6 +263,16 @@ self: super:
''; '';
}; };
# remove eth-hash dependency because eth-hash also depends on eth-utils causing a cycle.
eth-utils = super.eth-utils.overridePythonAttrs (old: {
propagatedBuildInputs =
builtins.filter (i: i.pname != "eth-hash") old.propagatedBuildInputs;
preConfigure = ''
${old.preConfigure or ""}
sed -i '/eth-hash/d' setup.py
'';
});
faker = super.faker.overridePythonAttrs ( faker = super.faker.overridePythonAttrs (
old: { old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ]; buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
@ -244,6 +290,10 @@ self: super:
} }
); );
fastecdsa = super.fastecdsa.overridePythonAttrs (old: {
buildInputs = old.buildInputs ++ [ pkgs.gmp.dev ];
});
fastparquet = super.fastparquet.overridePythonAttrs ( fastparquet = super.fastparquet.overridePythonAttrs (
old: { old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ]; buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
@ -313,11 +363,11 @@ self: super:
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ]; nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ];
buildInputs = buildInputs =
(old.buildInputs or [ ]) (old.buildInputs or [ ])
++ [ pkgs.hdf5 self.pkg-config self.cython ] ++ [ pkgs.hdf5 self.pkgconfig self.cython ]
++ lib.optional mpiSupport mpi ++ lib.optional mpiSupport mpi
; ;
propagatedBuildInputs = propagatedBuildInputs =
old.propagatedBuildInputs (old.propagatedBuildInputs or [ ])
++ lib.optionals mpiSupport [ self.mpi4py self.openssh ] ++ lib.optionals mpiSupport [ self.mpi4py self.openssh ]
; ;
preBuild = if mpiSupport then "export CC=${mpi}/bin/mpicc" else ""; preBuild = if mpiSupport then "export CC=${mpi}/bin/mpicc" else "";
@ -333,9 +383,25 @@ self: super:
) else old ) else old
); );
hid = super.hid.overridePythonAttrs (
old: {
postPatch = ''
found=
for name in libhidapi-hidraw libhidapi-libusb libhidapi-iohidmanager libhidapi; do
full_path=${pkgs.hidapi.out}/lib/$name${pkgs.stdenv.hostPlatform.extensions.sharedLibrary}
if test -f $full_path; then
found=t
sed -i -e "s|'$name\..*'|'$full_path'|" hid/__init__.py
fi
done
test -n "$found" || { echo "ERROR: No known libraries found in ${pkgs.hidapi.out}/lib, please update/fix this build expression."; exit 1; }
'';
}
);
horovod = super.horovod.overridePythonAttrs ( horovod = super.horovod.overridePythonAttrs (
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.mpi ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ pkgs.mpi ];
} }
); );
@ -399,7 +465,10 @@ self: super:
# 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 or [ ]) ++ lib.optional self.python.isPy2 self.pathlib2;
# disable the removal of pyproject.toml, required because of setuptools_scm
dontPreferSetupPy = true;
} }
); );
@ -411,7 +480,7 @@ self: super:
isort = super.isort.overridePythonAttrs ( isort = super.isort.overridePythonAttrs (
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.setuptools ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.setuptools ];
} }
); );
@ -453,7 +522,7 @@ self: super:
); );
jsonslicer = super.jsonslicer.overridePythonAttrs (old: { jsonslicer = super.jsonslicer.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ]; nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkgconfig ];
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.yajl ]; buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.yajl ];
}); });
@ -487,7 +556,7 @@ self: super:
lap = super.lap.overridePythonAttrs ( lap = super.lap.overridePythonAttrs (
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
self.numpy self.numpy
]; ];
} }
@ -512,7 +581,7 @@ self: super:
# Set directory containing llvm-config binary # Set directory containing llvm-config binary
preConfigure = '' preConfigure = ''
export LLVM_CONFIG=${pkgs.llvm.dev}/bin/llvm-config export LLVM_CONFIG=${pkgs.llvm}/bin/llvm-config
''; '';
__impureHostDeps = lib.optionals pkgs.stdenv.isDarwin [ "/usr/lib/libm.dylib" ]; __impureHostDeps = lib.optionals pkgs.stdenv.isDarwin [ "/usr/lib/libm.dylib" ];
@ -523,7 +592,7 @@ self: super:
lockfile = super.lockfile.overridePythonAttrs ( lockfile = super.lockfile.overridePythonAttrs (
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pbr ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.pbr ];
} }
); );
@ -570,7 +639,7 @@ self: super:
EOF EOF
''; '';
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
pkgs.libpng pkgs.libpng
pkgs.freetype pkgs.freetype
] ]
@ -650,7 +719,7 @@ self: super:
}; };
in in
{ {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.mpi ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ pkgs.mpi ];
enableParallelBuilding = true; enableParallelBuilding = true;
preBuild = '' preBuild = ''
ln -sf ${cfg} mpi.cfg ln -sf ${cfg} mpi.cfg
@ -670,8 +739,15 @@ self: super:
} }
); );
mypy = super.mypy.overridePythonAttrs (
old: {
MYPY_USE_MYPYC = pkgs.stdenv.buildPlatform.is64bit;
}
);
mysqlclient = super.mysqlclient.overridePythonAttrs ( mysqlclient = super.mysqlclient.overridePythonAttrs (
old: { old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.libmysqlclient ];
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.libmysqlclient ]; buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.libmysqlclient ];
} }
); );
@ -682,7 +758,7 @@ self: super:
self.cython self.cython
]; ];
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
pkgs.zlib pkgs.zlib
pkgs.netcdf pkgs.netcdf
pkgs.hdf5 pkgs.hdf5
@ -769,7 +845,7 @@ self: super:
in in
{ {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.sqlite ]; buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.sqlite ];
propagatedBuildInputs = old.propagatedBuildInputs or [ ] propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
++ lib.optional withPostgres self.psycopg2 ++ lib.optional withPostgres self.psycopg2
++ lib.optional withMysql self.mysql-connector; ++ lib.optional withMysql self.mysql-connector;
} }
@ -777,7 +853,7 @@ self: super:
pillow = super.pillow.overridePythonAttrs ( pillow = super.pillow.overridePythonAttrs (
old: { old: {
nativeBuildInputs = [ pkgs.pkg-config ] ++ (old.nativeBuildInputs or [ ]); nativeBuildInputs = [ pkgs.pkg-config self.pytest-runner ] ++ (old.nativeBuildInputs or [ ]);
buildInputs = with pkgs; [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ] ++ (old.buildInputs or [ ]); buildInputs = with pkgs; [ freetype libjpeg zlib libtiff libwebp tcl lcms2 ] ++ (old.buildInputs or [ ]);
} }
); );
@ -924,7 +1000,7 @@ self: super:
pkgs.pkg-config pkgs.pkg-config
]; ];
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
pkgs.cairo pkgs.cairo
pkgs.xlibsWrapper pkgs.xlibsWrapper
]; ];
@ -1028,6 +1104,16 @@ self: super:
} }
); );
pyproject-flake8 = super.pyproject-flake8.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.flit-core ];
}
);
pytezos = super.pytezos.override (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.libsodium ];
});
python-bugzilla = super.python-bugzilla.overridePythonAttrs ( python-bugzilla = super.python-bugzilla.overridePythonAttrs (
old: { old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
@ -1214,6 +1300,12 @@ self: super:
} }
); );
python-snappy = super.python-snappy.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.snappy ];
}
);
ffmpeg-python = super.ffmpeg-python.overridePythonAttrs ( ffmpeg-python = super.ffmpeg-python.overridePythonAttrs (
old: { old: {
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ]; buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
@ -1228,10 +1320,20 @@ self: super:
} }
); );
pyusb = super.pyusb.overridePythonAttrs (
old: {
postPatch = ''
libusb=${pkgs.libusb1.out}/lib/libusb-1.0${pkgs.stdenv.hostPlatform.extensions.sharedLibrary}
test -f $libusb || { echo "ERROR: $libusb doesn't exist, please update/fix this build expression."; exit 1; }
sed -i -e "s|find_library=None|find_library=lambda _:\"$libusb\"|" usb/backend/libusb1.py
'';
}
);
pyzmq = super.pyzmq.overridePythonAttrs ( pyzmq = super.pyzmq.overridePythonAttrs (
old: { old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ]; nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ];
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.zeromq ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ pkgs.zeromq ];
} }
); );
@ -1298,7 +1400,7 @@ self: super:
old: old:
if old.format != "wheel" then { if old.format != "wheel" then {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.gfortran ]; nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.gfortran ];
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.pybind11 ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.pybind11 ];
setupPyBuildFlags = [ "--fcompiler='gnu95'" ]; setupPyBuildFlags = [ "--fcompiler='gnu95'" ];
enableParallelBuilding = true; enableParallelBuilding = true;
buildInputs = (old.buildInputs or [ ]) ++ [ self.numpy.blas ]; buildInputs = (old.buildInputs or [ ]) ++ [ self.numpy.blas ];
@ -1329,6 +1431,17 @@ self: super:
} }
); );
secp256k1 = super.secp256k1.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkgconfig pkgs.autoconf pkgs.automake pkgs.libtool ];
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
doCheck = false;
# Local setuptools versions like "x.y.post0" confuse an internal check
postPatch = ''
substituteInPlace setup.py \
--replace 'setuptools_version.' '"${self.setuptools.version}".'
'';
});
shapely = super.shapely.overridePythonAttrs ( shapely = super.shapely.overridePythonAttrs (
old: { old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.geos self.cython ]; buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.geos self.cython ];
@ -1387,6 +1500,14 @@ self: super:
} }
); );
# The tokenizers build requires a complex rust setup (cf. nixpkgs override)
#
# Instead of providing a full source build, we use a wheel to keep
# the complexity manageable for now.
tokenizers = super.tokenizers.override {
preferWheel = true;
};
torch = lib.makeOverridable torch = lib.makeOverridable
({ enableCuda ? false ({ enableCuda ? false
, cudatoolkit ? pkgs.cudatoolkit_10_1 , cudatoolkit ? pkgs.cudatoolkit_10_1
@ -1415,11 +1536,34 @@ self: super:
propagatedBuildInputs = [ propagatedBuildInputs = [
self.numpy self.numpy
self.future self.future
self.typing-extensions
]; ];
}) })
) )
{ }; { };
torchvision = lib.makeOverridable
({ enableCuda ? false
, cudatoolkit ? pkgs.cudatoolkit_10_1
, pkg ? super.torchvision
}: pkg.overrideAttrs (old: {
# without that autoPatchelfHook will fail because cudatoolkit is not in LD_LIBRARY_PATH
autoPatchelfIgnoreMissingDeps = true;
buildInputs = (old.buildInputs or [ ])
++ [ self.torch ]
++ lib.optionals enableCuda [
cudatoolkit
];
preConfigure =
if (enableCuda) then ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${self.torch}/${self.python.sitePackages}/torch/lib:${lib.makeLibraryPath [ cudatoolkit "${cudatoolkit}" ]}"
'' else ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${self.torch}/${self.python.sitePackages}/torch/lib"
'';
}))
{ };
typeguard = super.typeguard.overridePythonAttrs (old: { typeguard = super.typeguard.overridePythonAttrs (old: {
postPatch = '' postPatch = ''
substituteInPlace setup.py \ substituteInPlace setup.py \
@ -1427,12 +1571,18 @@ self: super:
''; '';
}); });
typed_ast = super.typed-ast.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
self.pytest-runner
];
});
# nix uses a dash, poetry uses an underscore # nix uses a dash, poetry uses an underscore
typing_extensions = super.typing_extensions or self.typing-extensions; typing_extensions = super.typing_extensions or self.typing-extensions;
urwidtrees = super.urwidtrees.overridePythonAttrs ( urwidtrees = super.urwidtrees.overridePythonAttrs (
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
self.urwid self.urwid
]; ];
} }
@ -1476,6 +1626,7 @@ self: super:
weasyprint = super.weasyprint.overridePythonAttrs ( weasyprint = super.weasyprint.overridePythonAttrs (
old: { old: {
inherit (pkgs.python3.pkgs.weasyprint) patches; inherit (pkgs.python3.pkgs.weasyprint) patches;
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.pytest-runner ];
buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ]; buildInputs = (old.buildInputs or [ ]) ++ [ self.pytest-runner ];
} }
); );
@ -1524,7 +1675,7 @@ self: super:
) else super.zipp ) else super.zipp
).overridePythonAttrs ( ).overridePythonAttrs (
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
self.toml self.toml
]; ];
} }
@ -1551,9 +1702,38 @@ self: super:
} }
); );
psutil = super.psutil.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++
lib.optional stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.IOKit;
}
);
sentencepiece = super.sentencepiece.overridePythonAttrs (
old: {
dontUseCmakeConfigure = true;
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
pkgs.pkg-config
pkgs.cmake
pkgs.gperftools
];
buildInputs = (old.buildInputs or [ ]) ++ [
pkgs.sentencepiece
];
}
);
sentence-transformers = super.sentence-transformers.overridePythonAttrs (
old: {
buildInputs =
(old.buildInputs or [ ])
++ [ self.typing-extensions ];
}
);
supervisor = super.supervisor.overridePythonAttrs ( supervisor = super.supervisor.overridePythonAttrs (
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
self.meld3 self.meld3
self.setuptools self.setuptools
]; ];
@ -1562,7 +1742,7 @@ self: super:
cytoolz = super.cytoolz.overridePythonAttrs ( cytoolz = super.cytoolz.overridePythonAttrs (
old: { old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.toolz ]; propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.toolz ];
} }
); );
@ -1607,5 +1787,52 @@ self: super:
} }
); );
wxpython = super.wxpython.overridePythonAttrs (old:
let
localPython = self.python.withPackages (ps: with ps; [
setuptools
numpy
six
]);
in
{
DOXYGEN = "${pkgs.doxygen}/bin/doxygen";
nativeBuildInputs = with pkgs; [
which
doxygen
gtk3
pkg-config
autoPatchelfHook
] ++ (old.nativeBuildInputs or [ ]);
buildInputs = with pkgs; [
gtk3
webkitgtk
ncurses
SDL2
xorg.libXinerama
xorg.libSM
xorg.libXxf86vm
xorg.libXtst
xorg.xorgproto
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
libGLU
libGL
libglvnd
mesa
] ++ old.buildInputs;
buildPhase = ''
${localPython.interpreter} build.py -v build_wx
${localPython.interpreter} build.py -v dox etg --nodoc sip
${localPython.interpreter} build.py -v build_py
'';
installPhase = ''
${localPython.interpreter} setup.py install --skip-build --prefix=$out
'';
});
} }

View File

@ -129,7 +129,7 @@ let
if exprs.type == "expr" then if exprs.type == "expr" then
( (
let let
mVal = ''[a-zA-Z0-9\'"_\. ]+''; mVal = ''[a-zA-Z0-9\'"_\. \-]+'';
mOp = "in|[!=<>]+"; mOp = "in|[!=<>]+";
e = stripStr exprs.value; e = stripStr exprs.value;
m = builtins.map stripStr (builtins.match ''^(${mVal}) *(${mOp}) *(${mVal})$'' e); m = builtins.map stripStr (builtins.match ''^(${mVal}) *(${mOp}) *(${mVal})$'' e);