2022-04-27 09:35:20 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPythonPackage
|
2023-10-09 19:29:22 +00:00
|
|
|
, callPackage
|
2023-05-24 13:37:59 +00:00
|
|
|
, cargo
|
2024-02-29 20:09:43 +00:00
|
|
|
, certifi
|
2020-04-24 23:36:52 +00:00
|
|
|
, cffi
|
2024-01-25 14:12:00 +00:00
|
|
|
, cryptography-vectors ? (callPackage ./vectors.nix { })
|
2023-10-09 19:29:22 +00:00
|
|
|
, fetchPypi
|
2024-02-29 20:09:43 +00:00
|
|
|
, fetchpatch2
|
2023-08-10 07:59:29 +00:00
|
|
|
, isPyPy
|
|
|
|
, libiconv
|
|
|
|
, libxcrypt
|
|
|
|
, openssl
|
2023-04-29 16:46:19 +00:00
|
|
|
, pkg-config
|
2023-08-10 07:59:29 +00:00
|
|
|
, pretend
|
2024-02-29 20:09:43 +00:00
|
|
|
, pytest-xdist
|
2023-10-09 19:29:22 +00:00
|
|
|
, pytestCheckHook
|
2022-06-26 10:26:21 +00:00
|
|
|
, pythonOlder
|
2023-08-10 07:59:29 +00:00
|
|
|
, rustc
|
|
|
|
, rustPlatform
|
|
|
|
, Security
|
|
|
|
, setuptoolsRustBuildHook
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "cryptography";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "42.0.5"; # Also update the hash in vectors.nix
|
2024-01-02 11:29:13 +00:00
|
|
|
pyproject = true;
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-b+B+7JXf1HfrlTCu9b6tNP7IGbOq9sW9bSBWXaYHv+E=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
sourceRoot = "${pname}-${version}/${cargoRoot}";
|
|
|
|
name = "${pname}-${version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-Pw3ftpcDMfZr/w6US5fnnyPVsFSB9+BuIKazDocYjTU=";
|
2021-03-09 03:18:52 +00:00
|
|
|
};
|
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch2 {
|
|
|
|
# skip overflowing tests on 32 bit; https://github.com/pyca/cryptography/pull/10366
|
|
|
|
url = "https://github.com/pyca/cryptography/commit/d741901dddd731895346636c0d3556c6fa51fbe6.patch";
|
|
|
|
hash = "sha256-eC+MZg5O8Ia5CbjRE4y+JhaFs3Q5c62QtPHr3x9T+zw=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace pyproject.toml \
|
2024-02-29 20:09:43 +00:00
|
|
|
--replace-fail "--benchmark-disable" ""
|
2023-05-24 13:37:59 +00:00
|
|
|
'';
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
cargoRoot = "src/rust";
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
nativeBuildInputs = [
|
2021-03-09 03:18:52 +00:00
|
|
|
rustPlatform.cargoSetupHook
|
2023-08-10 07:59:29 +00:00
|
|
|
setuptoolsRustBuildHook
|
2023-05-24 13:37:59 +00:00
|
|
|
cargo
|
|
|
|
rustc
|
2023-07-15 17:15:38 +00:00
|
|
|
pkg-config
|
|
|
|
] ++ lib.optionals (!isPyPy) [
|
|
|
|
cffi
|
2023-05-24 13:37:59 +00:00
|
|
|
];
|
2020-12-03 08:41:04 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
buildInputs = [
|
|
|
|
openssl
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
Security
|
|
|
|
libiconv
|
|
|
|
] ++ lib.optionals (pythonOlder "3.9") [
|
|
|
|
libxcrypt
|
|
|
|
];
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = lib.optionals (!isPyPy) [
|
2020-12-03 08:41:04 +00:00
|
|
|
cffi
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2024-02-29 20:09:43 +00:00
|
|
|
certifi
|
2022-04-27 09:35:20 +00:00
|
|
|
cryptography-vectors
|
2020-04-24 23:36:52 +00:00
|
|
|
pretend
|
2022-04-27 09:35:20 +00:00
|
|
|
pytestCheckHook
|
2024-02-29 20:09:43 +00:00
|
|
|
pytest-xdist
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
pytestFlagsArray = [
|
2021-05-28 09:39:13 +00:00
|
|
|
"--disable-pytest-warnings"
|
2022-04-27 09:35:20 +00:00
|
|
|
];
|
2021-05-28 09:39:13 +00:00
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
disabledTestPaths = [
|
|
|
|
# save compute time by not running benchmarks
|
|
|
|
"tests/bench"
|
2022-04-27 09:35:20 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A package which provides cryptographic recipes and primitives";
|
|
|
|
longDescription = ''
|
|
|
|
Cryptography includes both high level recipes and low level interfaces to
|
|
|
|
common cryptographic algorithms such as symmetric ciphers, message
|
|
|
|
digests, and key derivation functions.
|
|
|
|
'';
|
|
|
|
homepage = "https://github.com/pyca/cryptography";
|
|
|
|
changelog = "https://cryptography.io/en/latest/changelog/#v"
|
|
|
|
+ replaceStrings [ "." ] [ "-" ] version;
|
|
|
|
license = with licenses; [ asl20 bsd3 psfl ];
|
2022-04-27 09:35:20 +00:00
|
|
|
maintainers = with maintainers; [ SuperSandro2000 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|