nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix

python3Packages.cnvkit: fix build error and failing tests (#431215)

authored by

Gaétan Lepage and committed by
GitHub
b14a5f5b 8998e096

+85 -55
+68 -18
pkgs/development/python-modules/cnvkit/default.nix
··· 3 3 buildPythonPackage, 4 4 fetchFromGitHub, 5 5 fetchpatch, 6 - 6 + python, 7 + makeWrapper, 7 8 # dependencies 8 - R, 9 9 biopython, 10 10 matplotlib, 11 11 numpy, ··· 13 13 pomegranate, 14 14 pyfaidx, 15 15 pysam, 16 - rPackages, 17 16 reportlab, 17 + rPackages, 18 18 scikit-learn, 19 19 scipy, 20 - 20 + R, 21 21 # tests 22 22 pytestCheckHook, 23 - }: 24 23 24 + }: 25 25 buildPythonPackage rec { 26 26 pname = "cnvkit"; 27 27 version = "0.9.12"; ··· 47 47 "pomegranate" 48 48 ]; 49 49 50 - # Numpy 2 compatibility 51 - postPatch = '' 52 - substituteInPlace skgenome/intersect.py \ 53 - --replace-fail "np.string_" "np.bytes_" 54 - ''; 50 + nativeBuildInputs = [ 51 + makeWrapper 52 + ]; 53 + 54 + buildInputs = [ 55 + R 56 + ]; 57 + 58 + postPatch = 59 + let 60 + rscript = lib.getExe' R "Rscript"; 61 + in 62 + # Numpy 2 compatibility 63 + '' 64 + substituteInPlace skgenome/intersect.py \ 65 + --replace-fail "np.string_" "np.bytes_" 66 + '' 67 + # Patch shebang lines in R scripts 68 + + '' 69 + substituteInPlace cnvlib/segmentation/flasso.py \ 70 + --replace-fail "#!/usr/bin/env Rscript" "#!${rscript}" 71 + 72 + substituteInPlace cnvlib/segmentation/cbs.py \ 73 + --replace-fail "#!/usr/bin/env Rscript" "#!${rscript}" 74 + 75 + substituteInPlace cnvlib/segmentation/__init__.py \ 76 + --replace-fail 'rscript_path="Rscript"' 'rscript_path="${rscript}"' 77 + 78 + substituteInPlace cnvlib/commands.py \ 79 + --replace-fail 'default="Rscript"' 'default="${rscript}"' 80 + 81 + ''; 55 82 56 83 dependencies = [ 57 84 biopython ··· 88 61 pomegranate 89 62 pyfaidx 90 63 pysam 91 - rPackages.DNAcopy 92 64 reportlab 65 + rPackages.DNAcopy 93 66 scikit-learn 94 67 scipy 95 68 ]; 69 + 70 + # Make sure R can find the DNAcopy package 71 + postInstall = '' 72 + wrapProgram $out/bin/cnvkit.py \ 73 + --set R_LIBS_SITE "${rPackages.DNAcopy}/library" \ 74 + --set MPLCONFIGDIR "/tmp/matplotlib-config" 75 + ''; 76 + 77 + installCheckPhase = '' 78 + runHook preInstallCheck 79 + 80 + ${python.executable} -m pytest --deselect=test/test_commands.py::CommandTests::test_batch \ 81 + --deselect=test/test_commands.py::CommandTests::test_segment_hmm 82 + 83 + cd test 84 + # Set matplotlib config directory for the tests 85 + export MPLCONFIGDIR="/tmp/matplotlib-config" 86 + export HOME="/tmp" 87 + mkdir -p "$MPLCONFIGDIR" 88 + 89 + # Use the installed binary - it's already wrapped with R_LIBS_SITE 90 + make cnvkit="$out/bin/cnvkit.py" || { 91 + echo "Make tests failed" 92 + exit 1 93 + } 94 + 95 + runHook postInstallCheck 96 + ''; 97 + 98 + doInstallCheck = true; 96 99 97 100 pythonImportsCheck = [ "cnvlib" ]; 98 101 99 102 nativeCheckInputs = [ 100 103 pytestCheckHook 101 104 R 102 - ]; 103 - 104 - disabledTests = [ 105 - # AttributeError: module 'pomegranate' has no attribute 'NormalDistribution' 106 - # https://github.com/etal/cnvkit/issues/815 107 - "test_batch" 108 - "test_segment_hmm" 109 105 ]; 110 106 111 107 meta = {
+17 -37
pkgs/development/python-modules/pomegranate/default.nix
··· 3 3 stdenv, 4 4 buildPythonPackage, 5 5 fetchFromGitHub, 6 - 7 - # build-system 6 + fetchpatch, 7 + pytestCheckHook, 8 8 setuptools, 9 - 10 - # dependencies 11 9 apricot-select, 12 10 networkx, 13 11 numpy, 14 12 scikit-learn, 15 13 scipy, 16 14 torch, 17 - 18 - # tests 19 - pytestCheckHook, 20 15 }: 21 16 22 17 buildPythonPackage rec { ··· 22 27 src = fetchFromGitHub { 23 28 repo = "pomegranate"; 24 29 owner = "jmschrei"; 25 - # tag = "v${version}"; 26 - # No tag for 1.1.2 27 - rev = "e9162731f4f109b7b17ecffde768734cacdb839b"; 28 - hash = "sha256-vVoAoZ+mph11ZfINT+yxRyk9rXv6FBDgxBz56P2K95Y="; 30 + tag = "v${version}"; 31 + hash = "sha256-p2Gn0FXnsAHvRUeAqx4M1KH0+XvDl3fmUZZ7MiMvPSs="; 29 32 }; 30 - 31 - # _pickle.UnpicklingError: Weights only load failed. 32 - # https://pytorch.org/docs/stable/generated/torch.load.html 33 - postPatch = '' 34 - substituteInPlace \ 35 - tests/distributions/test_bernoulli.py \ 36 - tests/distributions/test_categorical.py \ 37 - tests/distributions/test_exponential.py \ 38 - tests/distributions/test_gamma.py \ 39 - tests/distributions/test_independent_component.py \ 40 - tests/distributions/test_normal_diagonal.py \ 41 - tests/distributions/test_normal_full.py \ 42 - tests/distributions/test_poisson.py \ 43 - tests/distributions/test_student_t.py \ 44 - tests/distributions/test_uniform.py \ 45 - tests/test_bayes_classifier.py \ 46 - tests/test_gmm.py \ 47 - tests/test_kmeans.py \ 48 - --replace-fail \ 49 - 'torch.load(".pytest.torch")' \ 50 - 'torch.load(".pytest.torch", weights_only=False)' 51 - ''; 52 33 53 34 build-system = [ setuptools ]; 54 35 ··· 43 72 pytestCheckHook 44 73 ]; 45 74 46 - disabledTestPaths = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [ 75 + patches = [ 76 + # Fix tests for pytorch 2.6 77 + (fetchpatch { 78 + name = "python-2.6.patch"; 79 + url = "https://github.com/jmschrei/pomegranate/pull/1142/commits/9ff5d5e2c959b44e569937e777b26184d1752a7b.patch"; 80 + hash = "sha256-BXsVhkuL27QqK/n6Fa9oJCzrzNcL3EF6FblBeKXXSts="; 81 + }) 82 + ]; 83 + 84 + pytestFlagsArray = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [ 47 85 # AssertionError: Arrays are not almost equal to 6 decimals 48 - "=tests/distributions/test_normal_full.py::test_fit" 49 - "=tests/distributions/test_normal_full.py::test_from_summaries" 50 - "=tests/distributions/test_normal_full.py::test_serialization" 86 + "--deselect=tests/distributions/test_normal_full.py::test_fit" 87 + "--deselect=tests/distributions/test_normal_full.py::test_from_summaries" 88 + "--deselect=tests/distributions/test_normal_full.py::test_serialization" 51 89 ]; 52 90 53 91 disabledTests = [