2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2018-02-03 10:36:14 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
2019-09-13 18:47:04 +01:00
|
|
|
, fetchpatch
|
2021-02-08 13:07:11 +00:00
|
|
|
, rustPlatform
|
|
|
|
, setuptools-rust
|
2018-02-03 10:36:14 +00:00
|
|
|
, openssl
|
|
|
|
, cryptography_vectors
|
|
|
|
, darwin
|
|
|
|
, packaging
|
|
|
|
, six
|
|
|
|
, pythonOlder
|
|
|
|
, isPyPy
|
|
|
|
, cffi
|
|
|
|
, pytest
|
2021-02-08 13:07:11 +00:00
|
|
|
, pytest-subtests
|
2018-02-03 10:36:14 +00:00
|
|
|
, pretend
|
2021-05-19 18:02:23 +01:00
|
|
|
, libiconv
|
2018-02-03 10:36:14 +00:00
|
|
|
, iso8601
|
|
|
|
, pytz
|
|
|
|
, hypothesis
|
|
|
|
}:
|
|
|
|
|
2018-08-21 01:47:41 +01:00
|
|
|
buildPythonPackage rec {
|
2018-02-03 10:36:14 +00:00
|
|
|
pname = "cryptography";
|
2021-03-26 13:09:23 +00:00
|
|
|
version = "3.4.7"; # Also update the hash in vectors.nix
|
2018-02-03 10:36:14 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2021-03-26 13:09:23 +00:00
|
|
|
sha256 = "04x7bhjkglxpllad10821vxddlmxdkd3gjvp35iljmnj2s0xw41x";
|
2018-02-03 10:36:14 +00:00
|
|
|
};
|
|
|
|
|
2021-02-08 13:07:11 +00:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
sourceRoot = "${pname}-${version}/${cargoRoot}";
|
|
|
|
name = "${pname}-${version}";
|
2021-04-16 16:59:43 +01:00
|
|
|
sha256 = "1m6smky4nahwlp4hn6yzibrcxlbsw4nx162dsq48vlw8h1lgjl62";
|
2021-02-08 13:07:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cargoRoot = "src/rust";
|
|
|
|
|
2018-02-03 10:36:14 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2021-01-24 00:29:22 +00:00
|
|
|
nativeBuildInputs = lib.optionals (!isPyPy) [
|
2020-11-19 19:57:37 +00:00
|
|
|
cffi
|
2021-03-13 14:40:14 +00:00
|
|
|
] ++ [
|
2021-02-08 13:07:11 +00:00
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
setuptools-rust
|
|
|
|
] ++ (with rustPlatform; [ rust.cargo rust.rustc ]);
|
2020-11-19 19:57:37 +00:00
|
|
|
|
2019-03-30 16:13:09 +00:00
|
|
|
buildInputs = [ openssl ]
|
2021-05-19 18:02:23 +01:00
|
|
|
++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security libiconv ];
|
2018-02-03 10:36:14 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
packaging
|
|
|
|
six
|
2021-01-24 00:29:22 +00:00
|
|
|
] ++ lib.optionals (!isPyPy) [
|
2020-11-19 19:57:37 +00:00
|
|
|
cffi
|
|
|
|
];
|
2018-02-03 10:36:14 +00:00
|
|
|
|
|
|
|
checkInputs = [
|
2019-03-30 16:13:09 +00:00
|
|
|
cryptography_vectors
|
|
|
|
hypothesis
|
2018-02-03 10:36:14 +00:00
|
|
|
iso8601
|
2019-03-30 16:13:09 +00:00
|
|
|
pretend
|
|
|
|
pytest
|
2021-02-08 13:07:11 +00:00
|
|
|
pytest-subtests
|
2018-02-03 10:36:14 +00:00
|
|
|
pytz
|
|
|
|
];
|
|
|
|
|
2021-02-07 21:35:53 +00:00
|
|
|
pytestFlags = lib.concatStringsSep " " ([
|
|
|
|
"--disable-pytest-warnings"
|
|
|
|
] ++
|
|
|
|
lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
|
|
# aarch64-darwin forbids W+X memory, but this tests depends on it:
|
|
|
|
# * https://cffi.readthedocs.io/en/latest/using.html#callbacks
|
|
|
|
"--ignore=tests/hazmat/backends/test_openssl_memleak.py"
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2018-11-11 07:55:35 +00:00
|
|
|
checkPhase = ''
|
2021-02-07 21:35:53 +00:00
|
|
|
py.test ${pytestFlags} tests
|
2018-11-11 07:55:35 +00:00
|
|
|
'';
|
|
|
|
|
2018-02-03 10:36:14 +00:00
|
|
|
# IOKit's dependencies are inconsistent between OSX versions, so this is the best we
|
|
|
|
# can do until nix 1.11's release
|
|
|
|
__impureHostDeps = [ "/usr/lib" ];
|
2019-01-23 22:58:29 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-01-23 22:58:29 +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.
|
|
|
|
Our goal is for it to be your "cryptographic standard library". It
|
2020-04-03 14:36:19 +01:00
|
|
|
supports Python 2.7, Python 3.5+, and PyPy 5.4+.
|
2019-01-23 22:58:29 +00:00
|
|
|
'';
|
2020-04-03 14:36:19 +01:00
|
|
|
homepage = "https://github.com/pyca/cryptography";
|
|
|
|
changelog = "https://cryptography.io/en/latest/changelog/#v"
|
|
|
|
+ replaceStrings [ "." ] [ "-" ] version;
|
2019-01-23 22:58:29 +00:00
|
|
|
license = with licenses; [ asl20 bsd3 psfl ];
|
|
|
|
maintainers = with maintainers; [ primeos ];
|
|
|
|
};
|
2018-08-21 01:47:41 +01:00
|
|
|
}
|