summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/passlib/default.nix
blob: 396afc45dfbef3e40fcc7df9551bda1b5b0dfad6 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
  lib,
  buildPythonPackage,
  fetchFromGitLab,
  argon2-cffi,
  bcrypt,
  cryptography,
  pytestCheckHook,
  pythonOlder,
  pytest-xdist,
  setuptools,
}:

buildPythonPackage rec {
  pname = "passlib";
  version = "1.7.4";
  pyproject = true;

  disabled = pythonOlder "3.7";

  src = fetchFromGitLab {
    domain = "foss.heptapod.net";
    owner = "python-libs";
    repo = "passlib";
    rev = "refs/tags/${version}";
    hash = "sha256-Mx2Xg/KAEfvfep2B/gWATTiAPJc+f22MTcsEdRpt3n8=";
  };

  build-system = [ setuptools ];

  dependencies = [ setuptools ];

  optional-dependencies = {
    argon2 = [ argon2-cffi ];
    bcrypt = [ bcrypt ];
    totp = [ cryptography ];
  };

  # Fix for https://foss.heptapod.net/python-libs/passlib/-/issues/190
  postPatch = ''
    substituteInPlace passlib/handlers/bcrypt.py \
      --replace-fail "version = _bcrypt.__about__.__version__" \
      "version = getattr(getattr(_bcrypt, '__about__', _bcrypt), '__version__', '<unknown>')"
  '';

  nativeCheckInputs =
    [
      pytestCheckHook
      pytest-xdist
    ]
    ++ optional-dependencies.argon2
    ++ optional-dependencies.bcrypt
    ++ optional-dependencies.totp;

  pythonImportsCheck = [ "passlib" ];

  disabledTests = [
    # timming sensitive
    "test_dummy_verify"
    "test_encrypt_cost_timing"
    # These tests fail because they don't expect support for algorithms provided through libxcrypt
    "test_82_crypt_support"
  ];

  pytestFlagsArray = [
    # hashing algorithms we don't support anymore
    "--deselect=passlib/tests/test_handlers.py::des_crypt_os_crypt_test::test_82_crypt_support"
    "--deselect=passlib/tests/test_handlers.py::md5_crypt_os_crypt_test::test_82_crypt_support"
    "--deselect=passlib/tests/test_handlers.py::sha256_crypt_os_crypt_test::test_82_crypt_support"
  ];

  meta = {
    changelog = "https://foss.heptapod.net/python-libs/passlib/-/blob/${version}/docs/history/${lib.versions.majorMinor version}.rst";
    description = "Password hashing library for Python";
    homepage = "https://foss.heptapod.net/python-libs/passlib";
    license = lib.licenses.bsdOriginal;
    maintainers = with lib.maintainers; [ dotlambda ];
  };
}