diff --git a/pkgs/development/python-modules/cyvcf2/default.nix b/pkgs/development/python-modules/cyvcf2/default.nix new file mode 100644 index 000000000000..a29f7f21b2b7 --- /dev/null +++ b/pkgs/development/python-modules/cyvcf2/default.nix @@ -0,0 +1,89 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + python, + + # build-system + cmake, + cython, + ninja, + numpy, + scikit-build-core, + + # nativeBuildInputs + pkg-config, + + # buildInputs + htslib, + + # dependencies + click, + coloredlogs, + + # tests + pytestCheckHook, +}: + +buildPythonPackage (finalAttrs: { + pname = "cyvcf2"; + version = "0.34.0"; + pyproject = true; + __structuredAttrs = true; + + src = fetchFromGitHub { + owner = "brentp"; + repo = "cyvcf2"; + tag = "v${finalAttrs.version}"; + hash = "sha256-XDo2cEcZm5y6u9Gc2e7q2tg8pt3C/5cmnWRe6Dr5x7M="; + }; + + build-system = [ + cmake + cython + ninja + numpy + scikit-build-core + ]; + dontUseCmakeConfigure = true; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + htslib + ]; + + env = { + # Link against the system htslib instead of building the bundled submodule + CYVCF2_HTSLIB_MODE = "EXTERNAL"; + }; + + dependencies = [ + click + coloredlogs + numpy + ]; + + pythonImportsCheck = [ "cyvcf2" ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + # The test suite lives inside the package directory and relies on relative imports + # (`from ..cyvcf2 import VCF`) as well as data files next to it, so it must run from the source + # tree. Bring the compiled extension along. + preCheck = '' + cp $out/${python.sitePackages}/cyvcf2/cyvcf2*.so cyvcf2/ + ''; + + meta = { + description = "Cython wrapper around htslib built for fast parsing of Variant Call Format (VCF) files"; + homepage = "https://github.com/brentp/cyvcf2"; + changelog = "https://github.com/brentp/cyvcf2/blob/${finalAttrs.src.rev}/CHANGES.md"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ GaetanLepage ]; + }; +}) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index d8ba8c31a6e0..38c9e74c71e9 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3983,6 +3983,8 @@ self: super: with self; { cytoolz = callPackage ../development/python-modules/cytoolz { }; + cyvcf2 = callPackage ../development/python-modules/cyvcf2 { }; + cyvest = callPackage ../development/python-modules/cyvest { }; dacite = callPackage ../development/python-modules/dacite { };