at master 2.0 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 replaceVars, 6 cmdstan, 7 setuptools, 8 pandas, 9 numpy, 10 tqdm, 11 stanio, 12 xarray, 13 pytestCheckHook, 14 stdenv, 15}: 16 17buildPythonPackage rec { 18 pname = "cmdstanpy"; 19 version = "1.2.5"; 20 pyproject = true; 21 22 src = fetchFromGitHub { 23 owner = "stan-dev"; 24 repo = "cmdstanpy"; 25 tag = "v${version}"; 26 hash = "sha256-/MiWawB1Y4/eMBHXQLjd+P+Pe8EtsLbGFrzQa1RNf6g="; 27 }; 28 29 patches = [ 30 (replaceVars ./use-nix-cmdstan-path.patch { 31 cmdstan = "${cmdstan}/opt/cmdstan"; 32 }) 33 ]; 34 35 postPatch = '' 36 # conftest.py would have used git to clean up, which is unnecessary here 37 rm test/conftest.py 38 ''; 39 40 nativeBuildInputs = [ 41 setuptools 42 ]; 43 44 propagatedBuildInputs = [ 45 pandas 46 numpy 47 tqdm 48 stanio 49 ]; 50 51 optional-dependencies = { 52 all = [ xarray ]; 53 }; 54 55 pythonRelaxDeps = [ "stanio" ]; 56 57 preCheck = '' 58 export HOME=$(mktemp -d) 59 ''; 60 61 nativeCheckInputs = [ pytestCheckHook ] ++ optional-dependencies.all; 62 63 disabledTestPaths = [ 64 # No need to test these when using Nix 65 "test/test_install_cmdstan.py" 66 "test/test_cxx_installation.py" 67 ]; 68 69 disabledTests = [ 70 "test_serialization" # Pickle class mismatch errors 71 # These tests use the flag -DSTAN_THREADS which doesn't work in cmdstan (missing file) 72 "test_multi_proc_threads" 73 "test_compile_force" 74 # These tests require a writeable cmdstan source directory 75 "test_pathfinder_threads" 76 "test_save_profile" 77 ] 78 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 79 "test_init_types" # CmdStan error: error during processing Operation not permitted 80 ]; 81 82 pythonImportsCheck = [ "cmdstanpy" ]; 83 84 meta = { 85 homepage = "https://github.com/stan-dev/cmdstanpy"; 86 description = "Lightweight interface to Stan for Python users"; 87 changelog = "https://github.com/stan-dev/cmdstanpy/releases/tag/v${version}"; 88 license = lib.licenses.bsd3; 89 maintainers = with lib.maintainers; [ tomasajt ]; 90 }; 91}