pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / development / python-modules / cryptography / default.nix
blob63f6bf2850e72b910f4c258a16d4f859f6cc82d8
2   lib,
3   stdenv,
4   buildPythonPackage,
5   callPackage,
6   setuptools,
7   bcrypt,
8   certifi,
9   cffi,
10   cryptography-vectors ? (callPackage ./vectors.nix { }),
11   fetchPypi,
12   isPyPy,
13   libiconv,
14   libxcrypt,
15   openssl,
16   pkg-config,
17   pretend,
18   pytest-xdist,
19   pytestCheckHook,
20   pythonOlder,
21   rustPlatform,
22   Security,
25 buildPythonPackage rec {
26   pname = "cryptography";
27   version = "43.0.1"; # Also update the hash in vectors.nix
28   pyproject = true;
30   disabled = pythonOlder "3.7";
32   src = fetchPypi {
33     inherit pname version;
34     hash = "sha256-ID6Sp1cW2M+0kdxHx54X0NkgfM/8vLNfWY++RjrjRE0=";
35   };
37   cargoDeps = rustPlatform.fetchCargoTarball {
38     inherit src;
39     sourceRoot = "${pname}-${version}/${cargoRoot}";
40     name = "${pname}-${version}";
41     hash = "sha256-wiAHM0ucR1X7GunZX8V0Jk2Hsi+dVdGgDKqcYjSdD7Q=";
42   };
44   postPatch = ''
45     substituteInPlace pyproject.toml \
46       --replace-fail "--benchmark-disable" ""
47   '';
49   cargoRoot = "src/rust";
51   build-system = [
52     rustPlatform.cargoSetupHook
53     rustPlatform.maturinBuildHook
54     pkg-config
55     setuptools
56   ] ++ lib.optionals (!isPyPy) [ cffi ];
58   buildInputs =
59     [ openssl ]
60     ++ lib.optionals stdenv.hostPlatform.isDarwin [
61       Security
62       libiconv
63     ]
64     ++ lib.optionals (pythonOlder "3.9") [ libxcrypt ];
66   dependencies = lib.optionals (!isPyPy) [ cffi ];
68   optional-dependencies.ssh = [ bcrypt ];
70   nativeCheckInputs = [
71     certifi
72     cryptography-vectors
73     pretend
74     pytestCheckHook
75     pytest-xdist
76   ] ++ optional-dependencies.ssh;
78   pytestFlagsArray = [ "--disable-pytest-warnings" ];
80   disabledTestPaths = [
81     # save compute time by not running benchmarks
82     "tests/bench"
83   ];
85   passthru = {
86     vectors = cryptography-vectors;
87   };
89   meta = with lib; {
90     description = "Package which provides cryptographic recipes and primitives";
91     longDescription = ''
92       Cryptography includes both high level recipes and low level interfaces to
93       common cryptographic algorithms such as symmetric ciphers, message
94       digests, and key derivation functions.
95     '';
96     homepage = "https://github.com/pyca/cryptography";
97     changelog =
98       "https://cryptography.io/en/latest/changelog/#v" + replaceStrings [ "." ] [ "-" ] version;
99     license = with licenses; [
100       asl20
101       bsd3
102       psfl
103     ];
104     maintainers = with maintainers; [ SuperSandro2000 ];
105   };