1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitLab,
5 argon2-cffi,
6 bcrypt,
7 cryptography,
8 pytestCheckHook,
9 pythonOlder,
10 pytest-xdist,
11 setuptools,
12}:
13
14buildPythonPackage rec {
15 pname = "passlib";
16 version = "1.7.4";
17 pyproject = true;
18
19 disabled = pythonOlder "3.7";
20
21 src = fetchFromGitLab {
22 domain = "foss.heptapod.net";
23 owner = "python-libs";
24 repo = "passlib";
25 rev = "refs/tags/${version}";
26 hash = "sha256-Mx2Xg/KAEfvfep2B/gWATTiAPJc+f22MTcsEdRpt3n8=";
27 };
28
29 build-system = [ setuptools ];
30
31 dependencies = [ setuptools ];
32
33 optional-dependencies = {
34 argon2 = [ argon2-cffi ];
35 bcrypt = [ bcrypt ];
36 totp = [ cryptography ];
37 };
38
39 # Fix for https://foss.heptapod.net/python-libs/passlib/-/issues/190
40 postPatch = ''
41 substituteInPlace passlib/handlers/bcrypt.py \
42 --replace-fail "version = _bcrypt.__about__.__version__" \
43 "version = getattr(getattr(_bcrypt, '__about__', _bcrypt), '__version__', '<unknown>')"
44 '';
45
46 nativeCheckInputs =
47 [
48 pytestCheckHook
49 pytest-xdist
50 ]
51 ++ optional-dependencies.argon2
52 ++ optional-dependencies.bcrypt
53 ++ optional-dependencies.totp;
54
55 pythonImportsCheck = [ "passlib" ];
56
57 disabledTests = [
58 # timming sensitive
59 "test_dummy_verify"
60 "test_encrypt_cost_timing"
61 # These tests fail because they don't expect support for algorithms provided through libxcrypt
62 "test_82_crypt_support"
63 ];
64
65 pytestFlagsArray = [
66 # hashing algorithms we don't support anymore
67 "--deselect=passlib/tests/test_handlers.py::des_crypt_os_crypt_test::test_82_crypt_support"
68 "--deselect=passlib/tests/test_handlers.py::md5_crypt_os_crypt_test::test_82_crypt_support"
69 "--deselect=passlib/tests/test_handlers.py::sha256_crypt_os_crypt_test::test_82_crypt_support"
70 ];
71
72 meta = {
73 changelog = "https://foss.heptapod.net/python-libs/passlib/-/blob/${version}/docs/history/${lib.versions.majorMinor version}.rst";
74 description = "Password hashing library for Python";
75 homepage = "https://foss.heptapod.net/python-libs/passlib";
76 license = lib.licenses.bsdOriginal;
77 maintainers = with lib.maintainers; [ dotlambda ];
78 };
79}