1{ lib 2, stdenv 3, callPackage 4, buildPythonPackage 5, fetchPypi 6, rustPlatform 7, setuptools-rust 8, openssl 9, Security 10, packaging 11, six 12, isPyPy 13, cffi 14, pytestCheckHook 15, pytest-benchmark 16, pytest-subtests 17, pythonOlder 18, pretend 19, libiconv 20, iso8601 21, pytz 22, hypothesis 23}: 24 25let 26 cryptography-vectors = callPackage ./vectors.nix { }; 27in 28buildPythonPackage rec { 29 pname = "cryptography"; 30 version = "38.0.1"; # Also update the hash in vectors.nix 31 disabled = pythonOlder "3.6"; 32 33 src = fetchPypi { 34 inherit pname version; 35 hash = "sha256-HbPYB6FJMfoxf5ZDVpXZ7Dhr57hLYYzGHPpdCLCuM9c="; 36 }; 37 38 cargoDeps = rustPlatform.fetchCargoTarball { 39 inherit src; 40 sourceRoot = "${pname}-${version}/${cargoRoot}"; 41 name = "${pname}-${version}"; 42 hash = "sha256-o8l13fnfEUvUdDasq3LxSPArozRHKVsZfQg9DNR6M6Q="; 43 }; 44 45 cargoRoot = "src/rust"; 46 47 nativeBuildInputs = lib.optionals (!isPyPy) [ 48 cffi 49 ] ++ [ 50 rustPlatform.cargoSetupHook 51 setuptools-rust 52 ] ++ (with rustPlatform; [ rust.cargo rust.rustc ]); 53 54 buildInputs = [ openssl ] 55 ++ lib.optionals stdenv.isDarwin [ Security libiconv ]; 56 57 propagatedBuildInputs = lib.optionals (!isPyPy) [ 58 cffi 59 ]; 60 61 checkInputs = [ 62 cryptography-vectors 63 hypothesis 64 iso8601 65 pretend 66 pytestCheckHook 67 pytest-benchmark 68 pytest-subtests 69 pytz 70 ]; 71 72 pytestFlagsArray = [ 73 "--disable-pytest-warnings" 74 ]; 75 76 disabledTestPaths = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ 77 # aarch64-darwin forbids W+X memory, but this tests depends on it: 78 # * https://cffi.readthedocs.io/en/latest/using.html#callbacks 79 "tests/hazmat/backends/test_openssl_memleak.py" 80 ]; 81 82 meta = with lib; { 83 description = "A package which provides cryptographic recipes and primitives"; 84 longDescription = '' 85 Cryptography includes both high level recipes and low level interfaces to 86 common cryptographic algorithms such as symmetric ciphers, message 87 digests, and key derivation functions. 88 Our goal is for it to be your "cryptographic standard library". It 89 supports Python 2.7, Python 3.5+, and PyPy 5.4+. 90 ''; 91 homepage = "https://github.com/pyca/cryptography"; 92 changelog = "https://cryptography.io/en/latest/changelog/#v" 93 + replaceStrings [ "." ] [ "-" ] version; 94 license = with licenses; [ asl20 bsd3 psfl ]; 95 maintainers = with maintainers; [ SuperSandro2000 ]; 96 }; 97}