84 lines
1.6 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
cmake,
cython,
ninja,
scikit-build-core,
numpy,
hypothesis,
pandas,
pytestCheckHook,
rapidfuzz-cpp,
taskflow,
}:
buildPythonPackage rec {
pname = "rapidfuzz";
version = "3.13.0";
pyproject = true;
src = fetchFromGitHub {
owner = "maxbachmann";
repo = "RapidFuzz";
tag = "v${version}";
hash = "sha256-vwAqlTq4HIbmCL1HsHcgfVWETImxdqTsnenmX2RGXw8=";
};
build-system = [
cmake
cython
ninja
scikit-build-core
];
dontUseCmakeConfigure = true;
buildInputs = [
rapidfuzz-cpp
taskflow
];
env.RAPIDFUZZ_BUILD_EXTENSION = 1;
preBuild = lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) ''
export CMAKE_ARGS="-DCMAKE_CXX_COMPILER_AR=$AR -DCMAKE_CXX_COMPILER_RANLIB=$RANLIB"
'';
optional-dependencies = {
all = [ numpy ];
};
preCheck = ''
export RAPIDFUZZ_IMPLEMENTATION=cpp
'';
nativeCheckInputs = [
hypothesis
pandas
pytestCheckHook
];
disabledTests = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
# segfaults
"test_cdist"
];
pythonImportsCheck = [
"rapidfuzz.distance"
"rapidfuzz.fuzz"
"rapidfuzz.process"
"rapidfuzz.utils"
];
meta = {
description = "Rapid fuzzy string matching";
homepage = "https://github.com/maxbachmann/RapidFuzz";
changelog = "https://github.com/maxbachmann/RapidFuzz/blob/${src.tag}/CHANGELOG.rst";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ dotlambda ];
};
}