lol

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 ··· 61 88 pomegranate 62 89 pyfaidx 63 90 pysam 64 - rPackages.DNAcopy 65 91 reportlab 92 + rPackages.DNAcopy 66 93 scikit-learn 67 94 scipy 68 95 ]; 69 96 97 + # Make sure R can find the DNAcopy package 98 + postInstall = '' 99 + wrapProgram $out/bin/cnvkit.py \ 100 + --set R_LIBS_SITE "${rPackages.DNAcopy}/library" \ 101 + --set MPLCONFIGDIR "/tmp/matplotlib-config" 102 + ''; 103 + 104 + installCheckPhase = '' 105 + runHook preInstallCheck 106 + 107 + ${python.executable} -m pytest --deselect=test/test_commands.py::CommandTests::test_batch \ 108 + --deselect=test/test_commands.py::CommandTests::test_segment_hmm 109 + 110 + cd test 111 + # Set matplotlib config directory for the tests 112 + export MPLCONFIGDIR="/tmp/matplotlib-config" 113 + export HOME="/tmp" 114 + mkdir -p "$MPLCONFIGDIR" 115 + 116 + # Use the installed binary - it's already wrapped with R_LIBS_SITE 117 + make cnvkit="$out/bin/cnvkit.py" || { 118 + echo "Make tests failed" 119 + exit 1 120 + } 121 + 122 + runHook postInstallCheck 123 + ''; 124 + 125 + doInstallCheck = true; 126 + 70 127 pythonImportsCheck = [ "cnvlib" ]; 71 128 72 129 nativeCheckInputs = [ 73 130 pytestCheckHook 74 131 R 75 - ]; 76 - 77 - disabledTests = [ 78 - # AttributeError: module 'pomegranate' has no attribute 'NormalDistribution' 79 - # https://github.com/etal/cnvkit/issues/815 80 - "test_batch" 81 - "test_segment_hmm" 82 132 ]; 83 133 84 134 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 { ··· 27 22 src = fetchFromGitHub { 28 23 repo = "pomegranate"; 29 24 owner = "jmschrei"; 30 - # tag = "v${version}"; 31 - # No tag for 1.1.2 32 - rev = "e9162731f4f109b7b17ecffde768734cacdb839b"; 33 - hash = "sha256-vVoAoZ+mph11ZfINT+yxRyk9rXv6FBDgxBz56P2K95Y="; 25 + tag = "v${version}"; 26 + hash = "sha256-p2Gn0FXnsAHvRUeAqx4M1KH0+XvDl3fmUZZ7MiMvPSs="; 34 27 }; 35 28 36 - # _pickle.UnpicklingError: Weights only load failed. 37 - # https://pytorch.org/docs/stable/generated/torch.load.html 38 - postPatch = '' 39 - substituteInPlace \ 40 - tests/distributions/test_bernoulli.py \ 41 - tests/distributions/test_categorical.py \ 42 - tests/distributions/test_exponential.py \ 43 - tests/distributions/test_gamma.py \ 44 - tests/distributions/test_independent_component.py \ 45 - tests/distributions/test_normal_diagonal.py \ 46 - tests/distributions/test_normal_full.py \ 47 - tests/distributions/test_poisson.py \ 48 - tests/distributions/test_student_t.py \ 49 - tests/distributions/test_uniform.py \ 50 - tests/test_bayes_classifier.py \ 51 - tests/test_gmm.py \ 52 - tests/test_kmeans.py \ 53 - --replace-fail \ 54 - 'torch.load(".pytest.torch")' \ 55 - 'torch.load(".pytest.torch", weights_only=False)' 56 - ''; 57 - 58 29 build-system = [ setuptools ]; 59 30 60 31 dependencies = [ ··· 72 43 pytestCheckHook 73 44 ]; 74 45 75 - disabledTestPaths = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [ 46 + patches = [ 47 + # Fix tests for pytorch 2.6 48 + (fetchpatch { 49 + name = "python-2.6.patch"; 50 + url = "https://github.com/jmschrei/pomegranate/pull/1142/commits/9ff5d5e2c959b44e569937e777b26184d1752a7b.patch"; 51 + hash = "sha256-BXsVhkuL27QqK/n6Fa9oJCzrzNcL3EF6FblBeKXXSts="; 52 + }) 53 + ]; 54 + 55 + pytestFlagsArray = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [ 76 56 # AssertionError: Arrays are not almost equal to 6 decimals 77 - "=tests/distributions/test_normal_full.py::test_fit" 78 - "=tests/distributions/test_normal_full.py::test_from_summaries" 79 - "=tests/distributions/test_normal_full.py::test_serialization" 57 + "--deselect=tests/distributions/test_normal_full.py::test_fit" 58 + "--deselect=tests/distributions/test_normal_full.py::test_from_summaries" 59 + "--deselect=tests/distributions/test_normal_full.py::test_serialization" 80 60 ]; 81 61 82 62 disabledTests = [