2023-07-12 13:33:05 +02:00
|
|
|
{ lib
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, substituteAll
|
|
|
|
, cmdstan
|
2024-01-13 18:38:24 +01:00
|
|
|
, pythonRelaxDepsHook
|
|
|
|
, setuptools
|
2023-07-12 13:33:05 +02:00
|
|
|
, pandas
|
|
|
|
, numpy
|
|
|
|
, tqdm
|
2023-10-07 20:25:38 +02:00
|
|
|
, stanio
|
2023-07-12 13:33:05 +02:00
|
|
|
, xarray
|
|
|
|
, pytestCheckHook
|
2024-01-30 09:42:06 +01:00
|
|
|
, stdenv
|
2023-07-12 13:33:05 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "cmdstanpy";
|
2024-02-07 01:49:29 +01:00
|
|
|
version = "1.2.1";
|
2024-01-13 18:38:24 +01:00
|
|
|
pyproject = true;
|
2023-07-12 13:33:05 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "stan-dev";
|
|
|
|
repo = "cmdstanpy";
|
|
|
|
rev = "refs/tags/v${version}";
|
2024-02-07 01:49:29 +01:00
|
|
|
hash = "sha256-q+AFhWEzjYElJpiHT4h6YfZrwZJ56pv+8R+001vREyQ=";
|
2023-07-12 13:33:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2024-01-13 18:38:24 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
setuptools
|
|
|
|
pythonRelaxDepsHook
|
|
|
|
];
|
|
|
|
|
2023-07-12 13:33:05 +02:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
pandas
|
|
|
|
numpy
|
|
|
|
tqdm
|
2023-10-07 20:25:38 +02:00
|
|
|
stanio
|
2023-07-12 13:33:05 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
passthru.optional-dependencies = {
|
|
|
|
all = [ xarray ];
|
|
|
|
};
|
|
|
|
|
2024-01-13 18:38:24 +01:00
|
|
|
pythonRelaxDeps = [ "stanio" ];
|
|
|
|
|
2023-07-12 13:33:05 +02:00
|
|
|
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_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"
|
2024-01-30 09:42:06 +01:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
"test_init_types" # CmdStan error: error during processing Operation not permitted
|
2023-07-12 13:33:05 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
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;
|
|
|
|
maintainers = with lib.maintainers; [ tomasajt ];
|
|
|
|
};
|
|
|
|
}
|