diff --git a/pkgs/development/libraries/rapidfuzz-cpp/default.nix b/pkgs/development/libraries/rapidfuzz-cpp/default.nix new file mode 100644 index 0000000000000..10b63ce82f83b --- /dev/null +++ b/pkgs/development/libraries/rapidfuzz-cpp/default.nix @@ -0,0 +1,29 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +}: + +stdenv.mkDerivation rec { + pname = "rapidfuzz-cpp"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "maxbachmann"; + repo = pname; + rev = "v${version}"; + sha256 = "1g30ckm78ixsd06s067saaqbw97mkxyhfn75dr0ql7i3j9ghz7mw"; + }; + + nativeBuildInputs = [ cmake ]; + + cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" ]; + + meta = with lib; { + description = "Rapid fuzzy string matching in C++ using the Levenshtein Distance"; + homepage = "https://github.com/maxbachmann/rapidfuzz-cpp"; + license = licenses.mit; + maintainers = with maintainers; [ fab ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/development/python-modules/levenshtein/default.nix b/pkgs/development/python-modules/levenshtein/default.nix index e5f743e0fe11e..2ba032055e02a 100644 --- a/pkgs/development/python-modules/levenshtein/default.nix +++ b/pkgs/development/python-modules/levenshtein/default.nix @@ -2,29 +2,52 @@ , buildPythonPackage , fetchFromGitHub , pythonOlder -, pytestCheckHook +, python +, cmake +, ninja +, cython +, scikit-build +, setuptools +, rapidfuzz-cpp , rapidfuzz +, pytestCheckHook }: buildPythonPackage rec { pname = "levenshtein"; version = "0.18.1"; - format = "setuptools"; + format = "pyproject"; disabled = pythonOlder "3.6"; src = fetchFromGitHub { owner = "maxbachmann"; - repo = "Levenshtein"; + repo = pname; rev = "v${version}"; - sha256 = "sha256-3p9LM4tv45bqeTsuyngivqfd5uml7uqGB2ICKqPa0qY="; + fetchSubmodules = true; + sha256 = "sha256-WREYdD5MFOpCzH4BSceRpzQZdpi3Xxxn0DpMvDsNlGo="; }; postPatch = '' - substituteInPlace setup.cfg \ - --replace "rapidfuzz >= 1.8.2, < 1.9" "rapidfuzz" + substituteInPlace setup.py \ + --replace ", < 3.0.0" "" + + substituteInPlace pyproject.toml \ + --replace "Cython==3.0.0a10" "Cython>=0.29.0" ''; + nativeBuildInputs = [ + cmake + ninja + cython + scikit-build + setuptools + ]; + + buildInputs = [ + rapidfuzz-cpp + ]; + propagatedBuildInputs = [ rapidfuzz ]; @@ -33,6 +56,12 @@ buildPythonPackage rec { pytestCheckHook ]; + dontUseCmakeConfigure = true; + + cmakeFlags = [ + "-DCMAKE_MODULE_PATH=${python.pkgs.scikit-build}/${python.sitePackages}/skbuild/resources/cmake" + ]; + pythonImportsCheck = [ "Levenshtein" ]; @@ -42,5 +71,6 @@ buildPythonPackage rec { homepage = "https://github.com/maxbachmann/Levenshtein"; license = licenses.gpl2Plus; maintainers = with maintainers; [ fab ]; + platforms = platforms.all; }; } diff --git a/pkgs/development/python-modules/rapidfuzz-capi/default.nix b/pkgs/development/python-modules/rapidfuzz-capi/default.nix new file mode 100644 index 0000000000000..735c6f02ae935 --- /dev/null +++ b/pkgs/development/python-modules/rapidfuzz-capi/default.nix @@ -0,0 +1,26 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +}: + +buildPythonPackage rec { + pname = "rapidfuzz-capi"; + version = "1.0.2"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "maxbachmann"; + repo = "rapidfuzz_capi"; + rev = "v.${version}"; + sha256 = "127mwjbyp2nfj846bxb3aajmhsgzfx4wfvizpnwb30yv2fcrpy7l"; + }; + + pythonImportsCheck = [ "rapidfuzz_capi" ]; + + meta = with lib; { + description = "C-API of RapidFuzz, which can be used to extend RapidFuzz from separate packages"; + homepage = "https://github.com/maxbachmann/rapidfuzz_capi"; + license = licenses.mit; + maintainers = with maintainers; [ dotlambda ]; + }; +} diff --git a/pkgs/development/python-modules/rapidfuzz/default.nix b/pkgs/development/python-modules/rapidfuzz/default.nix index 19ee86e93ab6d..5128f5188d467 100644 --- a/pkgs/development/python-modules/rapidfuzz/default.nix +++ b/pkgs/development/python-modules/rapidfuzz/default.nix @@ -2,34 +2,60 @@ , buildPythonPackage , pythonOlder , fetchFromGitHub -, pytestCheckHook +, cmake +, cython +, scikit-build +, python +, numpy +, rapidfuzz-capi , hypothesis , pandas -, numpy +, pytestCheckHook }: buildPythonPackage rec { pname = "rapidfuzz"; - version = "1.9.1"; + version = "2.0.8"; + format = "pyproject"; - disabled = pythonOlder "3.5"; + disabled = pythonOlder "3.6"; src = fetchFromGitHub { owner = "maxbachmann"; - repo = "RapidFuzz"; + repo = pname; rev = "v${version}"; fetchSubmodules = true; - sha256 = "sha256-aZqsQHrxmPqZARkqR1hWaj7XndOlCJjmWk1Cosx4skA="; + sha256 = "sha256-LA4UpP3jFcVZTYKuq8aBvfGgEhyOLeCUsUXEgSnwb94="; }; + nativeBuildInputs = [ + cmake + cython + scikit-build + ]; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace "==" ">=" \ + --replace "Cython==3.0.0a10" "Cython>=0.29.0" \ + --replace "scikit-build>=0.13.0" "scikit-build>=0.12.0" + ''; + + dontUseCmakeConfigure = true; + + cmakeFlags = [ + "-DCMAKE_MODULE_PATH=${scikit-build}/${python.sitePackages}/skbuild/resources/cmake" + ]; + propagatedBuildInputs = [ numpy + rapidfuzz-capi ]; checkInputs = [ - pytestCheckHook hypothesis pandas + pytestCheckHook ]; disabledTests = [ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f36274a9ddb1f..95ce3713729fe 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19886,6 +19886,8 @@ with pkgs; rapidcheck = callPackage ../development/libraries/rapidcheck {}; + rapidfuzz-cpp = callPackage ../development/libraries/rapidfuzz-cpp {}; + rapidjson = callPackage ../development/libraries/rapidjson {}; rapidxml = callPackage ../development/libraries/rapidxml {}; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 5aaf35c45a457..6911d48eaa86b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8669,6 +8669,8 @@ in { rapidfuzz = callPackage ../development/python-modules/rapidfuzz { }; + rapidfuzz-capi = callPackage ../development/python-modules/rapidfuzz-capi { }; + rarfile = callPackage ../development/python-modules/rarfile { inherit (pkgs) libarchive; };