depot/third_party/nixpkgs/pkgs/development/python-modules/pymongo-inmemory/default.nix
Default email 5c370c0b2a Project import generated by Copybara.
GitOrigin-RevId: 33d1e753c82ffc557b4a585c77de43d4c922ebb5
2024-05-15 17:35:15 +02:00

70 lines
1.6 KiB
Nix

{ lib
, buildPythonPackage
, pythonOlder
, fetchFromGitHub
, fetchpatch
, poetry-core
, pymongo
, pytestCheckHook
}:
buildPythonPackage rec {
pname = "pymongo-inmemory";
version = "0.4.1";
format = "pyproject";
disabled = pythonOlder "3.7";
src = fetchFromGitHub {
owner = "kaizendorks";
repo = "pymongo_inmemory";
rev = "refs/tags/v${version}";
hash = "sha256-vYWVMSawk+03ie3PtqOyzd6wxiviq+IzyQ8bvEHNHfc=";
};
postPatch = ''
# move cache location from nix store to home
substituteInPlace pymongo_inmemory/context.py \
--replace-fail \
'CACHE_FOLDER = path.join(path.dirname(__file__), "..", ".cache")' \
'CACHE_FOLDER = os.environ.get("XDG_CACHE_HOME", os.environ["HOME"] + "/.cache") + "/pymongo-inmemory"'
# fix a broken assumption arising from the above fix
substituteInPlace pymongo_inmemory/_utils.py \
--replace-fail \
'os.mkdir(current_path)' \
'os.makedirs(current_path)'
'';
nativeBuildInputs = [
poetry-core
];
dependencies = [
pymongo
];
nativeCheckInputs = [
pytestCheckHook
];
disabledTestPaths = [
# new test with insufficient monkey patching, try to remove on next bump
"tests/unit/test_mongod.py"
];
preCheck = ''
export HOME="$(mktemp -d)"
'';
pythonImportsCheck = [
"pymongo_inmemory"
];
meta = {
homepage = "https://github.com/kaizendorks/pymongo_inmemory";
description = "A mongo mocking library with an ephemeral MongoDB running in memory";
maintainers = with lib.maintainers; [ pbsds ];
license = lib.licenses.mit;
};
}