Skip to content

Commit

Permalink
faiss: 1.8.0 -> 1.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahec committed Oct 5, 2024
1 parent e32e37f commit a4b5751
Showing 1 changed file with 8 additions and 43 deletions.
51 changes: 8 additions & 43 deletions pkgs/development/libraries/science/math/faiss/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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-D++SeKuI7UoD7JlDY1MQlY0JnE1AAPQJyuCym/tSUrk=";
};

# 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 [
Expand Down Expand Up @@ -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

Expand All @@ -114,28 +94,15 @@ 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/"
'';
postInstall = 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;
};
Expand All @@ -148,7 +115,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;
};
}

0 comments on commit a4b5751

Please sign in to comment.