1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 callPackage, 6 setuptools, 7 bcrypt, 8 certifi, 9 cffi, 10 cryptography-vectors ? (callPackage ./vectors.nix { }), 11 fetchFromGitHub, 12 isPyPy, 13 libiconv, 14 libxcrypt, 15 openssl, 16 pkg-config, 17 pretend, 18 pytest-xdist, 19 pytestCheckHook, 20 pythonOlder, 21 rustPlatform, 22}: 23 24buildPythonPackage rec { 25 pname = "cryptography"; 26 version = "44.0.2"; # Also update the hash in vectors.nix 27 pyproject = true; 28 29 disabled = pythonOlder "3.7"; 30 31 src = fetchFromGitHub { 32 owner = "pyca"; 33 repo = "cryptography"; 34 tag = version; 35 hash = "sha256-nXwW6v+U47/+CmjhREHcuQ7QQi/b26gagWBQ3F16DuQ="; 36 }; 37 38 cargoDeps = rustPlatform.fetchCargoVendor { 39 inherit src; 40 name = "${pname}-${version}"; 41 hash = "sha256-HbUsV+ABE89UvhCRZYXr+Q/zRDKUy+HgCVdQFHqaP4o="; 42 }; 43 44 postPatch = '' 45 substituteInPlace pyproject.toml \ 46 --replace-fail "--benchmark-disable" "" 47 ''; 48 49 build-system = [ 50 rustPlatform.cargoSetupHook 51 rustPlatform.maturinBuildHook 52 pkg-config 53 setuptools 54 ] ++ lib.optionals (!isPyPy) [ cffi ]; 55 56 buildInputs = 57 [ openssl ] 58 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 59 libiconv 60 ] 61 ++ lib.optionals (pythonOlder "3.9") [ libxcrypt ]; 62 63 dependencies = lib.optionals (!isPyPy) [ cffi ]; 64 65 optional-dependencies.ssh = [ bcrypt ]; 66 67 nativeCheckInputs = [ 68 certifi 69 cryptography-vectors 70 pretend 71 pytestCheckHook 72 pytest-xdist 73 ] ++ optional-dependencies.ssh; 74 75 pytestFlagsArray = [ "--disable-pytest-warnings" ]; 76 77 disabledTestPaths = [ 78 # save compute time by not running benchmarks 79 "tests/bench" 80 ]; 81 82 passthru = { 83 vectors = cryptography-vectors; 84 }; 85 86 meta = with lib; { 87 description = "Package which provides cryptographic recipes and primitives"; 88 longDescription = '' 89 Cryptography includes both high level recipes and low level interfaces to 90 common cryptographic algorithms such as symmetric ciphers, message 91 digests, and key derivation functions. 92 ''; 93 homepage = "https://github.com/pyca/cryptography"; 94 changelog = 95 "https://cryptography.io/en/latest/changelog/#v" + replaceStrings [ "." ] [ "-" ] version; 96 license = with licenses; [ 97 asl20 98 bsd3 99 psfl 100 ]; 101 maintainers = with maintainers; [ SuperSandro2000 ]; 102 }; 103}