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 openssl, 15 pkg-config, 16 pretend, 17 pytest-xdist, 18 pytestCheckHook, 19 pythonOlder, 20 rustPlatform, 21}: 22 23buildPythonPackage rec { 24 pname = "cryptography"; 25 version = "45.0.4"; # Also update the hash in vectors.nix 26 pyproject = true; 27 28 disabled = pythonOlder "3.7"; 29 30 src = fetchFromGitHub { 31 owner = "pyca"; 32 repo = "cryptography"; 33 tag = version; 34 hash = "sha256-rKgMUVj5IdeWIdLWQ4E6zhC6dwJMi+BRHCh2JG73Zgc="; 35 }; 36 37 cargoDeps = rustPlatform.fetchCargoVendor { 38 inherit pname version src; 39 hash = "sha256-dKwNnWBzBM9QEcRbbvkNhFJnFxFakqZ/MS7rqE8/tNQ="; 40 }; 41 42 postPatch = '' 43 substituteInPlace pyproject.toml \ 44 --replace-fail "--benchmark-disable" "" 45 ''; 46 47 build-system = [ 48 rustPlatform.cargoSetupHook 49 rustPlatform.maturinBuildHook 50 pkg-config 51 setuptools 52 ] 53 ++ lib.optionals (!isPyPy) [ cffi ]; 54 55 buildInputs = [ 56 openssl 57 ] 58 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 59 libiconv 60 ]; 61 62 dependencies = lib.optionals (!isPyPy) [ cffi ]; 63 64 optional-dependencies.ssh = [ bcrypt ]; 65 66 nativeCheckInputs = [ 67 certifi 68 cryptography-vectors 69 pretend 70 pytestCheckHook 71 pytest-xdist 72 ] 73 ++ optional-dependencies.ssh; 74 75 pytestFlags = [ "--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}