2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
callPackage,
|
|
|
|
cargo,
|
|
|
|
certifi,
|
|
|
|
cffi,
|
|
|
|
cryptography-vectors ? (callPackage ./vectors.nix { }),
|
|
|
|
fetchPypi,
|
|
|
|
fetchpatch2,
|
|
|
|
isPyPy,
|
|
|
|
libiconv,
|
|
|
|
libxcrypt,
|
|
|
|
openssl,
|
|
|
|
pkg-config,
|
|
|
|
pretend,
|
|
|
|
pytest-xdist,
|
|
|
|
pytestCheckHook,
|
|
|
|
pythonOlder,
|
|
|
|
rustc,
|
|
|
|
rustPlatform,
|
|
|
|
Security,
|
|
|
|
setuptoolsRustBuildHook,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "cryptography";
|
2024-07-31 10:19:44 +00:00
|
|
|
version = "42.0.8"; # 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-07-31 10:19:44 +00:00
|
|
|
hash = "sha256-jQnQVDnOe6qOnpWwfsW2yIb1SN634Pae8l9ks7zoQvI=";
|
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-07-31 10:19:44 +00:00
|
|
|
hash = "sha256-PgxPcFocEhnQyrsNtCN8YHiMptBmk1PUhEDQFdUR1nU=";
|
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
|
2024-06-05 15:53:02 +00:00
|
|
|
] ++ lib.optionals (!isPyPy) [ cffi ];
|
2020-12-03 08:41:04 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
buildInputs =
|
|
|
|
[ openssl ]
|
|
|
|
++ lib.optionals stdenv.isDarwin [
|
|
|
|
Security
|
|
|
|
libiconv
|
|
|
|
]
|
|
|
|
++ lib.optionals (pythonOlder "3.9") [ libxcrypt ];
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
propagatedBuildInputs = lib.optionals (!isPyPy) [ 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
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pytestFlagsArray = [ "--disable-pytest-warnings" ];
|
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; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Package which provides cryptographic recipes and primitives";
|
2020-04-24 23:36:52 +00:00
|
|
|
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";
|
2024-06-05 15:53:02 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|