at master 2.0 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 bzip2, 6 bcftools, 7 curl, 8 cython, 9 htslib, 10 libdeflate, 11 xz, 12 pytestCheckHook, 13 setuptools, 14 samtools, 15 zlib, 16 nix-update-script, 17}: 18 19buildPythonPackage rec { 20 pname = "pysam"; 21 version = "0.23.3"; 22 pyproject = true; 23 24 # Fetching from GitHub instead of PyPi cause the 0.13 src release on PyPi is 25 # missing some files which cause test failures. 26 # Tracked at: https://github.com/pysam-developers/pysam/issues/616 27 src = fetchFromGitHub { 28 owner = "pysam-developers"; 29 repo = "pysam"; 30 tag = "v${version}"; 31 hash = "sha256-yOLnfuGQW+j0nHy4MRlwurZMpeRHTGmQ9eLmihcAGoQ="; 32 }; 33 34 build-system = [ 35 cython 36 setuptools 37 ]; 38 39 nativeBuildInputs = [ 40 samtools 41 ]; 42 43 buildInputs = [ 44 bzip2 45 curl 46 libdeflate 47 xz 48 zlib 49 ]; 50 51 # Use nixpkgs' htslib instead of the bundled one 52 # See https://pysam.readthedocs.io/en/latest/installation.html#external 53 # NOTE that htslib should be version compatible with pysam 54 preBuild = '' 55 export HTSLIB_MODE=shared 56 export HTSLIB_LIBRARY_DIR=${htslib}/lib 57 export HTSLIB_INCLUDE_DIR=${htslib}/include 58 ''; 59 60 nativeCheckInputs = [ 61 pytestCheckHook 62 bcftools 63 htslib 64 ]; 65 66 preCheck = '' 67 export HOME=$TMPDIR 68 make -C tests/pysam_data 69 make -C tests/cbcf_data 70 make -C tests/tabix_data 71 rm -rf pysam 72 ''; 73 74 pythonImportsCheck = [ 75 "pysam" 76 "pysam.bcftools" 77 "pysam.libchtslib" 78 "pysam.libcutils" 79 "pysam.libcvcf" 80 "pysam.libcsamtools" 81 ]; 82 83 passthru.updateScript = nix-update-script { }; 84 85 meta = { 86 description = "Python module for reading, manipulating and writing genome data sets"; 87 downloadPage = "https://github.com/pysam-developers/pysam"; 88 changelog = "https://github.com/pysam-developers/pysam/releases/tag/${src.tag}"; 89 homepage = "https://pysam.readthedocs.io"; 90 maintainers = with lib.maintainers; [ unode ]; 91 license = lib.licenses.mit; 92 platforms = lib.platforms.unix; 93 }; 94}