From 0a41e3f9386d0ac6156bd83732ac287caa21e838 Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Sat, 17 Oct 2020 12:37:40 +0200 Subject: [PATCH] pythonPackages.pysam: add libdeflate and enable tests Some tests still fail due to upstream reasons so we skip those. Note also that we are not using nix's pytestCheckHook due to pysam detecting how it's loaded which conflicts with how pytestCheckHook runs tests. In addition, the selection mode used by disabledTests causes more tests than the failing ones to be skipped, which is undesired. See the discussion in https://github.com/NixOS/nixpkgs/pull/100823 --- .../python-modules/pysam/default.nix | 63 +++++++++++++++++-- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/pkgs/development/python-modules/pysam/default.nix b/pkgs/development/python-modules/pysam/default.nix index 6c7a44f2649..2802b6d0e0f 100644 --- a/pkgs/development/python-modules/pysam/default.nix +++ b/pkgs/development/python-modules/pysam/default.nix @@ -6,6 +6,7 @@ , curl , cython , htslib +, libdeflate , lzma , pytest , samtools @@ -27,22 +28,72 @@ buildPythonPackage rec { }; nativeBuildInputs = [ samtools ]; - buildInputs = [ bzip2 curl cython lzma zlib ]; + buildInputs = [ + bzip2 + curl + cython + libdeflate + lzma + zlib + ]; - checkInputs = [ pytest bcftools htslib ]; - checkPhase = "py.test"; + # Use nixpkgs' htslib instead of the bundled one + # See https://pysam.readthedocs.io/en/latest/installation.html#external + # NOTE that htslib should be version compatible with pysam + preBuild = '' + export HTSLIB_MODE=shared + export HTSLIB_LIBRARY_DIR=${htslib}/lib + export HTSLIB_INCLUDE_DIR=${htslib}/include + ''; - # tests require samtools<=1.9 - doCheck = false; - preCheck = '' + checkInputs = [ + pytest + bcftools + htslib + ]; + + # See https://github.com/NixOS/nixpkgs/pull/100823 for why we aren't using + # disabledTests and pytestFlagsArray through pytestCheckHook + checkPhase = '' + # Needed to avoid /homeless-shelter error export HOME=$(mktemp -d) + + # To avoid API incompatibilities, these should ideally show the same version + echo "> samtools --version" + samtools --version + echo "> htsfile --version" + htsfile --version + echo "> bcftools --version" + bcftools --version + + # Create auxiliary test data make -C tests/pysam_data make -C tests/cbcf_data + + # Delete pysam folder in current directory to avoid importing it during testing + rm -rf pysam + + # Deselect tests that are known to fail due to upstream issues + # See https://github.com/pysam-developers/pysam/issues/961 + py.test \ + --deselect tests/AlignmentFileHeader_test.py::TestHeaderBAM::test_dictionary_access_works \ + --deselect tests/AlignmentFileHeader_test.py::TestHeaderBAM::test_header_content_is_as_expected \ + --deselect tests/AlignmentFileHeader_test.py::TestHeaderCRAM::test_dictionary_access_works \ + --deselect tests/AlignmentFileHeader_test.py::TestHeaderCRAM::test_header_content_is_as_expected \ + --deselect tests/AlignmentFile_test.py::TestIO::testBAM2SAM \ + --deselect tests/AlignmentFile_test.py::TestIO::testSAM2BAM \ + --deselect tests/AlignmentFile_test.py::TestIO::testWriteUncompressedBAMFile \ + --deselect tests/AlignmentFile_test.py::TestDeNovoConstruction::testBAMWholeFile \ + --deselect tests/AlignmentFile_test.py::TestEmptyHeader::testEmptyHeader \ + --deselect tests/AlignmentFile_test.py::TestHeaderWithProgramOptions::testHeader \ + --deselect tests/StreamFiledescriptors_test.py::StreamTest::test_text_processing \ + tests/ ''; pythonImportsCheck = [ "pysam" "pysam.bcftools" + "pysam.libchtslib" "pysam.libcutils" "pysam.libcvcf" ];