1{ stdenv
2, buildPythonPackage
3, fetchPypi
4, openssl
5, cryptography_vectors
6, darwin
7, asn1crypto
8, packaging
9, six
10, pythonOlder
11, enum34
12, ipaddress
13, isPyPy
14, cffi
15, pytest
16, pretend
17, iso8601
18, pytz
19, hypothesis
20}:
21
22buildPythonPackage rec {
23 # also bump cryptography_vectors
24 pname = "cryptography";
25 version = "2.5";
26
27 src = fetchPypi {
28 inherit pname version;
29 sha256 = "00c4d7gvsymlaw0r13zrm32dcnarmpayjyrh65yymlmr6mrbcij9";
30 };
31
32 outputs = [ "out" "dev" ];
33
34 buildInputs = [ openssl cryptography_vectors ]
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 pytest
46 pretend
47 iso8601
48 pytz
49 hypothesis
50 ];
51
52 checkPhase = ''
53 py.test --disable-pytest-warnings tests
54 '';
55
56 # The test assumes that if we're on Sierra or higher, that we use `getentropy`, but for binary
57 # compatibility with pre-Sierra for binary caches, we hide that symbol so the library doesn't
58 # use it. This boils down to them checking compatibility with `getentropy` in two different places,
59 # so let's neuter the second test.
60 postPatch = ''
61 substituteInPlace ./tests/hazmat/backends/test_openssl.py --replace '"16.0"' '"99.0"'
62 '';
63
64 # IOKit's dependencies are inconsistent between OSX versions, so this is the best we
65 # can do until nix 1.11's release
66 __impureHostDeps = [ "/usr/lib" ];
67
68 meta = with stdenv.lib; {
69 description = "A package which provides cryptographic recipes and primitives";
70 longDescription = ''
71 Cryptography includes both high level recipes and low level interfaces to
72 common cryptographic algorithms such as symmetric ciphers, message
73 digests, and key derivation functions.
74 Our goal is for it to be your "cryptographic standard library". It
75 supports Python 2.7, Python 3.4+, and PyPy 5.3+.
76 '';
77 homepage = https://github.com/pyca/cryptography;
78 license = with licenses; [ asl20 bsd3 psfl ];
79 maintainers = with maintainers; [ primeos ];
80 };
81}