Skip to content

Commit

Permalink
python312Packages.pesq: init at 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Oct 22, 2024
1 parent c53153d commit dbf7e26
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
77 changes: 77 additions & 0 deletions pkgs/development/python-modules/pesq/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 { };
Expand Down

0 comments on commit dbf7e26

Please sign in to comment.