1{ 2 lib, 3 buildPythonPackage, 4 pythonOlder, 5 fetchFromGitHub, 6 fetchpatch, 7 poetry-core, 8 pymongo, 9 pytestCheckHook, 10}: 11 12buildPythonPackage rec { 13 pname = "pymongo-inmemory"; 14 version = "0.4.1"; 15 format = "pyproject"; 16 17 disabled = pythonOlder "3.7"; 18 19 src = fetchFromGitHub { 20 owner = "kaizendorks"; 21 repo = "pymongo_inmemory"; 22 rev = "refs/tags/v${version}"; 23 hash = "sha256-vYWVMSawk+03ie3PtqOyzd6wxiviq+IzyQ8bvEHNHfc="; 24 }; 25 26 postPatch = '' 27 # move cache location from nix store to home 28 substituteInPlace pymongo_inmemory/context.py \ 29 --replace-fail \ 30 'CACHE_FOLDER = path.join(path.dirname(__file__), "..", ".cache")' \ 31 'CACHE_FOLDER = os.environ.get("XDG_CACHE_HOME", os.environ["HOME"] + "/.cache") + "/pymongo-inmemory"' 32 33 # fix a broken assumption arising from the above fix 34 substituteInPlace pymongo_inmemory/_utils.py \ 35 --replace-fail \ 36 'os.mkdir(current_path)' \ 37 'os.makedirs(current_path)' 38 ''; 39 40 nativeBuildInputs = [ poetry-core ]; 41 42 dependencies = [ pymongo ]; 43 44 nativeCheckInputs = [ pytestCheckHook ]; 45 46 disabledTestPaths = [ 47 # new test with insufficient monkey patching, try to remove on next bump 48 "tests/unit/test_mongod.py" 49 ]; 50 51 preCheck = '' 52 export HOME="$(mktemp -d)" 53 ''; 54 55 pythonImportsCheck = [ "pymongo_inmemory" ]; 56 57 meta = { 58 homepage = "https://github.com/kaizendorks/pymongo_inmemory"; 59 description = "A mongo mocking library with an ephemeral MongoDB running in memory"; 60 maintainers = with lib.maintainers; [ pbsds ]; 61 license = lib.licenses.mit; 62 }; 63}