nixpkgs/pkgs/development/python-modules/cmdstanpy/default.nix
2023-07-18 17:06:35 +02:00

83 lines
1.7 KiB
Nix

{ lib
, buildPythonPackage
, fetchFromGitHub
, substituteAll
, cmdstan
, pandas
, numpy
, tqdm
, xarray
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "cmdstanpy";
version = "1.1.0";
format = "setuptools";
src = fetchFromGitHub {
owner = "stan-dev";
repo = "cmdstanpy";
rev = "refs/tags/v${version}";
hash = "sha256-9kAd3rbSctWEhAzB6RiQlbg5/uVxGIghYLus8hWzBFQ=";
};
patches = [
(substituteAll {
src = ./use-nix-cmdstan-path.patch;
cmdstan = "${cmdstan}/opt/cmdstan";
})
];
postPatch = ''
# conftest.py would have used git to clean up, which is unnecessary here
rm test/conftest.py
'';
propagatedBuildInputs = [
pandas
numpy
tqdm
];
passthru.optional-dependencies = {
all = [ xarray ];
};
preCheck = ''
export HOME=$(mktemp -d)
'';
nativeCheckInputs = [
pytestCheckHook
] ++ passthru.optional-dependencies.all;
disabledTestPaths = [
# No need to test these when using Nix
"test/test_install_cmdstan.py"
"test/test_cxx_installation.py"
];
disabledTests = [
"test_lp_good" # Fails for some reason
"test_serialization" # Pickle class mismatch errors
# These tests use the flag -DSTAN_THREADS which doesn't work in cmdstan (missing file)
"test_multi_proc_threads"
"test_compile_force"
];
pythonImportsCheck = [ "cmdstanpy" ];
meta = {
homepage = "https://github.com/stan-dev/cmdstanpy";
description = "A lightweight interface to Stan for Python users";
changelog = "https://github.com/stan-dev/cmdstanpy/releases/tag/v${version}";
license = lib.licenses.bsd3;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [ tomasajt ];
};
}