diff --git a/pkgs/development/python-modules/pesq/default.nix b/pkgs/development/python-modules/pesq/default.nix new file mode 100644 index 000000000000..d8111f3a4531 --- /dev/null +++ b/pkgs/development/python-modules/pesq/default.nix @@ -0,0 +1,77 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + # build-system + cython, + numpy, + setuptools, + + # tests + pytestCheckHook, + scipy, +}: + +buildPythonPackage rec { + pname = "pesq"; + version = "0.0.4"; + pyproject = true; + + src = fetchFromGitHub { + owner = "ludlows"; + repo = "PESQ"; + rev = "refs/tags/v${version}"; + hash = "sha256-JuwZ+trFKGMetS3cC3pEQsV+wbj6+klFnC3THOd8bPE="; + }; + + postPatch = + # pythonRemoveDeps does not work for removing pytest-runner + '' + substituteInPlace setup.py \ + --replace-fail ", 'pytest-runner'" "" + '' + # Flaky tests: numerical equality is not satisfied on ARM platforms + + '' + substituteInPlace tests/test_pesq.py \ + --replace-fail \ + "assert score == 1.6072081327438354" \ + "assert abs(score - 1.6072081327438354) < 1e-5" \ + --replace-fail \ + "assert score == [1.6072081327438354]" \ + "assert np.allclose(np.array(score), np.array([1.6072081327438354]))" + ''; + + build-system = [ + cython + setuptools + numpy + ]; + + dependencies = [ + numpy + ]; + + pythonImportsCheck = [ + "pesq" + "pesq.cypesq" + ]; + + # Prevents importing the `pesq` module from the source files (which lack the cypesq extension) + preCheck = '' + rm -rf pesq + ''; + + nativeCheckInputs = [ + pytestCheckHook + scipy + ]; + + meta = { + description = "PESQ (Perceptual Evaluation of Speech Quality) Wrapper for Python Users"; + homepage = "https://github.com/ludlows/PESQ"; + changelog = "https://github.com/ludlows/PESQ/releases/tag/v${version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 61fd9424c546..5b40377a1784 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -9890,6 +9890,8 @@ self: super: with self; { pescea = callPackage ../development/python-modules/pescea { }; + pesq = callPackage ../development/python-modules/pesq { }; + pex = callPackage ../development/python-modules/pex { }; pexif = callPackage ../development/python-modules/pexif { };