1{ stdenv
2, buildPythonPackage
3, fetchPypi
4, fetchpatch
5, openssl
6, cryptography_vectors
7, darwin
8, asn1crypto
9, packaging
10, six
11, pythonOlder
12, enum34
13, ipaddress
14, isPyPy
15, cffi
16, pytest
17, pretend
18, iso8601
19, pytz
20, hypothesis
21}:
22
23buildPythonPackage rec {
24 pname = "cryptography";
25 version = "2.7"; # Also update the hash in vectors.nix
26
27 src = fetchPypi {
28 inherit pname version;
29 sha256 = "1inlnr36kl36551c9rcad99jmhk81v33by3glkadwdcgmi17fd76";
30 };
31
32 outputs = [ "out" "dev" ];
33
34 buildInputs = [ openssl ]
35 ++ stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security;
36 propagatedBuildInputs = [
37 asn1crypto
38 packaging
39 six
40 ] ++ stdenv.lib.optional (pythonOlder "3.4") enum34
41 ++ stdenv.lib.optional (pythonOlder "3.3") ipaddress
42 ++ stdenv.lib.optional (!isPyPy) cffi;
43
44 checkInputs = [
45 cryptography_vectors
46 hypothesis
47 iso8601
48 pretend
49 pytest
50 pytz
51 ];
52
53 # remove when https://github.com/pyca/cryptography/issues/4998 is fixed
54 checkPhase = ''
55 py.test --disable-pytest-warnings tests -k 'not load_ecdsa_no_named_curve'
56 '';
57
58 patches = [
59 (fetchpatch {
60 url = "https://github.com/pyca/cryptography/commit/e575e3d482f976c4a1f3203d63ea0f5007a49a2a.patch";
61 sha256 = "0vg9prqsizd6gzh5j7lscsfxzxlhz7pacvzhgqmj1vhdhjwbblcp";
62 })
63 ];
64
65 # IOKit's dependencies are inconsistent between OSX versions, so this is the best we
66 # can do until nix 1.11's release
67 __impureHostDeps = [ "/usr/lib" ];
68
69 meta = with stdenv.lib; {
70 description = "A package which provides cryptographic recipes and primitives";
71 longDescription = ''
72 Cryptography includes both high level recipes and low level interfaces to
73 common cryptographic algorithms such as symmetric ciphers, message
74 digests, and key derivation functions.
75 Our goal is for it to be your "cryptographic standard library". It
76 supports Python 2.7, Python 3.4+, and PyPy 5.3+.
77 '';
78 homepage = https://github.com/pyca/cryptography;
79 license = with licenses; [ asl20 bsd3 psfl ];
80 maintainers = with maintainers; [ primeos ];
81 };
82}