faiss: 1.8.0->1.9.0 (#341418)

This commit is contained in:
Someone
2024-10-09 21:52:20 +00:00
committed by GitHub

View File

@@ -21,13 +21,11 @@
in
# Choose the maximum available optimization level
builtins.head optLevels,
faiss, # To run demos in the tests
runCommand,
}@inputs:
let
pname = "faiss";
version = "1.8.0";
version = "1.9.0";
inherit (cudaPackages) flags backendStdenv;
@@ -46,27 +44,15 @@ in
stdenv.mkDerivation {
inherit pname version;
outputs = [
"out"
"demos"
] ++ lib.optionals pythonSupport [ "dist" ];
outputs = [ "out" ] ++ lib.optionals pythonSupport [ "dist" ];
src = fetchFromGitHub {
owner = "facebookresearch";
repo = pname;
rev = "v${version}";
hash = "sha256-nS8nhkNGGb2oAJKfr/MIAZjAwMxBGbNd16/CkEtv67I=";
hash = "sha256-P8TynU6jz5NbcWLdI7n4LX5Gdz0Ks72bmOzQ3LGjQCQ=";
};
# Remove the following substituteInPlace when updating
# to a release that contains change from PR
# https://github.com/facebookresearch/faiss/issues/3239
# that fixes building faiss with swig 4.2.x
postPatch = ''
substituteInPlace faiss/python/swigfaiss.swig \
--replace-fail '#ifdef SWIGWORDSIZE64' '#if (__SIZEOF_LONG__ == 8)'
'';
nativeBuildInputs =
[ cmake ]
++ lib.optionals cudaSupport [
@@ -99,13 +85,7 @@ stdenv.mkDerivation {
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" flags.cmakeCudaArchitecturesString)
];
buildFlags =
[ "faiss" ]
# This is just a demo app used as a test.
# Disabled because linkage fails:
# https://github.com/facebookresearch/faiss/issues/3484
++ lib.optionals (!cudaSupport) [ "demo_ivfpq_indexing" ]
++ lib.optionals pythonSupport [ "swigfaiss" ];
buildFlags = [ "faiss" ] ++ lib.optionals pythonSupport [ "swigfaiss" ];
# pip wheel->pip install commands copied over from opencv4
@@ -114,32 +94,10 @@ stdenv.mkDerivation {
python -m pip wheel --verbose --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist .)
'';
postInstall =
''
mkdir -p $demos/bin
if [[ "$buildInputs" == *demo_ivfpq_indexing* ]] ; then
cp ./demos/demo_ivfpq_indexing $demos/bin/
fi
''
+ lib.optionalString pythonSupport ''
mkdir "$dist"
cp faiss/python/dist/*.whl "$dist/"
'';
passthru = {
inherit cudaSupport cudaPackages pythonSupport;
tests = {
runDemos =
runCommand "${pname}-run-demos" { buildInputs = [ faiss.demos ]; }
# There are more demos, we run just the one that documentation mentions
''
demo_ivfpq_indexing && touch $out
'';
pythonFaiss = pythonPackages.faiss;
pytest = pythonPackages.faiss.tests.pytest;
};
};
postInstall = lib.optionalString pythonSupport ''
mkdir "$dist"
cp faiss/python/dist/*.whl "$dist/"
'';
meta = {
description = "Library for efficient similarity search and clustering of dense vectors by Facebook Research";
@@ -148,7 +106,5 @@ stdenv.mkDerivation {
license = lib.licenses.mit;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ SomeoneSerge ];
# error: use of undeclared identifier 'SWIGTYPE_p_long'
broken = stdenv.hostPlatform.isDarwin;
};
}