Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / python-modules / cryptography / default.nix
blob4671f607bbac7960178eb3d0c94016dee43c71eb
1 { lib, stdenv
2 , buildPythonPackage
3 , fetchPypi
4 , fetchpatch
5 , rustPlatform
6 , setuptools-rust
7 , openssl
8 , cryptography_vectors
9 , darwin
10 , packaging
11 , six
12 , pythonOlder
13 , isPyPy
14 , cffi
15 , pytest
16 , pytest-subtests
17 , pretend
18 , iso8601
19 , pytz
20 , hypothesis
23 buildPythonPackage rec {
24   pname = "cryptography";
25   version = "3.4.7"; # Also update the hash in vectors.nix
27   src = fetchPypi {
28     inherit pname version;
29     sha256 = "04x7bhjkglxpllad10821vxddlmxdkd3gjvp35iljmnj2s0xw41x";
30   };
32   cargoDeps = rustPlatform.fetchCargoTarball {
33     inherit src;
34     sourceRoot = "${pname}-${version}/${cargoRoot}";
35     name = "${pname}-${version}";
36     sha256 = "1wisxmq26b8ml144m2458sgcbk8jpv419j01qmffsrfy50x9i1yw";
37   };
39   cargoRoot = "src/rust";
41   outputs = [ "out" "dev" ];
43   nativeBuildInputs = lib.optionals (!isPyPy) [
44     cffi
45   ] ++ [
46     rustPlatform.cargoSetupHook
47     setuptools-rust
48   ] ++ (with rustPlatform; [ rust.cargo rust.rustc ]);
50   buildInputs = [ openssl ]
51              ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
52   propagatedBuildInputs = [
53     packaging
54     six
55   ] ++ lib.optionals (!isPyPy) [
56     cffi
57   ];
59   checkInputs = [
60     cryptography_vectors
61     hypothesis
62     iso8601
63     pretend
64     pytest
65     pytest-subtests
66     pytz
67   ];
69   checkPhase = ''
70     py.test --disable-pytest-warnings tests
71   '';
73   # IOKit's dependencies are inconsistent between OSX versions, so this is the best we
74   # can do until nix 1.11's release
75   __impureHostDeps = [ "/usr/lib" ];
77   meta = with lib; {
78     description = "A package which provides cryptographic recipes and primitives";
79     longDescription = ''
80       Cryptography includes both high level recipes and low level interfaces to
81       common cryptographic algorithms such as symmetric ciphers, message
82       digests, and key derivation functions.
83       Our goal is for it to be your "cryptographic standard library". It
84       supports Python 2.7, Python 3.5+, and PyPy 5.4+.
85     '';
86     homepage = "https://github.com/pyca/cryptography";
87     changelog = "https://cryptography.io/en/latest/changelog/#v"
88       + replaceStrings [ "." ] [ "-" ] version;
89     license = with licenses; [ asl20 bsd3 psfl ];
90     maintainers = with maintainers; [ primeos ];
91   };