1{ lib 2, buildPythonPackage 3, fetchFromGitHub 4, substituteAll 5 6, cmdstan 7 8, pandas 9, numpy 10, tqdm 11, stanio 12, xarray 13 14, pytestCheckHook 15}: 16 17buildPythonPackage rec { 18 pname = "cmdstanpy"; 19 version = "1.2.0"; 20 format = "setuptools"; 21 22 src = fetchFromGitHub { 23 owner = "stan-dev"; 24 repo = "cmdstanpy"; 25 rev = "refs/tags/v${version}"; 26 hash = "sha256-1/X5JDvCx21qLNamNQXpg+w3d3DdSRlB+liIv2fThs4="; 27 }; 28 29 patches = [ 30 (substituteAll { 31 src = ./use-nix-cmdstan-path.patch; 32 cmdstan = "${cmdstan}/opt/cmdstan"; 33 }) 34 ]; 35 36 postPatch = '' 37 # conftest.py would have used git to clean up, which is unnecessary here 38 rm test/conftest.py 39 ''; 40 41 propagatedBuildInputs = [ 42 pandas 43 numpy 44 tqdm 45 stanio 46 ]; 47 48 passthru.optional-dependencies = { 49 all = [ xarray ]; 50 }; 51 52 preCheck = '' 53 export HOME=$(mktemp -d) 54 ''; 55 56 nativeCheckInputs = [ 57 pytestCheckHook 58 ] ++ passthru.optional-dependencies.all; 59 60 disabledTestPaths = [ 61 # No need to test these when using Nix 62 "test/test_install_cmdstan.py" 63 "test/test_cxx_installation.py" 64 ]; 65 66 disabledTests = [ 67 "test_lp_good" # Fails for some reason 68 "test_serialization" # Pickle class mismatch errors 69 # These tests use the flag -DSTAN_THREADS which doesn't work in cmdstan (missing file) 70 "test_multi_proc_threads" 71 "test_compile_force" 72 ]; 73 74 pythonImportsCheck = [ "cmdstanpy" ]; 75 76 meta = { 77 homepage = "https://github.com/stan-dev/cmdstanpy"; 78 description = "A lightweight interface to Stan for Python users"; 79 changelog = "https://github.com/stan-dev/cmdstanpy/releases/tag/v${version}"; 80 license = lib.licenses.bsd3; 81 platforms = lib.platforms.linux; 82 maintainers = with lib.maintainers; [ tomasajt ]; 83 }; 84}