python310Packages.cmdstanpy: init at 1.1.0

This commit is contained in:
TomaSajt
2023-07-18 17:06:35 +02:00
parent a5ca6a0f2e
commit 4df9ed01d3
3 changed files with 109 additions and 0 deletions
@@ -0,0 +1,82 @@
{ 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 ];
};
}
@@ -0,0 +1,25 @@
diff --git a/cmdstanpy/utils/cmdstan.py b/cmdstanpy/utils/cmdstan.py
index 227d97a..27c3ccc 100644
--- a/cmdstanpy/utils/cmdstan.py
+++ b/cmdstanpy/utils/cmdstan.py
@@ -163,19 +163,7 @@ def cmdstan_path() -> str:
if 'CMDSTAN' in os.environ and len(os.environ['CMDSTAN']) > 0:
cmdstan = os.environ['CMDSTAN']
else:
- cmdstan_dir = os.path.expanduser(os.path.join('~', _DOT_CMDSTAN))
- if not os.path.exists(cmdstan_dir):
- raise ValueError(
- 'No CmdStan installation found, run command "install_cmdstan"'
- 'or (re)activate your conda environment!'
- )
- latest_cmdstan = get_latest_cmdstan(cmdstan_dir)
- if latest_cmdstan is None:
- raise ValueError(
- 'No CmdStan installation found, run command "install_cmdstan"'
- 'or (re)activate your conda environment!'
- )
- cmdstan = os.path.join(cmdstan_dir, latest_cmdstan)
+ cmdstan = '@cmdstan@'
os.environ['CMDSTAN'] = cmdstan
validate_cmdstan_path(cmdstan)
return os.path.normpath(cmdstan)
+2
View File
@@ -2001,6 +2001,8 @@ self: super: with self; {
cmdline = callPackage ../development/python-modules/cmdline { };
cmdstanpy = callPackage ../development/python-modules/cmdstanpy { };
cmigemo = callPackage ../development/python-modules/cmigemo {
inherit (pkgs) cmigemo;
};