python313Packages.traits: fix build (#373698)
[NixPkgs.git] / pkgs / development / python-modules / oscrypto / default.nix
blobef90df289af647972c3d0e76fd030152016f52cc
2   lib,
3   stdenv,
4   asn1crypto,
5   buildPythonPackage,
6   fetchFromGitHub,
7   fetchpatch,
8   openssl,
9   pytestCheckHook,
10   pythonOlder,
13 buildPythonPackage rec {
14   pname = "oscrypto";
15   version = "1.3.0";
16   format = "setuptools";
18   disabled = pythonOlder "3.7";
20   src = fetchFromGitHub {
21     owner = "wbond";
22     repo = pname;
23     rev = version;
24     hash = "sha256-CmDypmlc/kb6ONCUggjT1Iqd29xNSLRaGh5Hz36dvOw=";
25   };
27   patches = [
28     ./support-openssl-3.0.10.patch
30     (fetchpatch {
31       # backport removal of imp module usage
32       url = "https://github.com/wbond/oscrypto/commit/3865f5d528740aa1205d16ddbee84c5b48aeb078.patch";
33       hash = "sha256-lQGoPM7EicwCPWapEDkqWEqMqXk4tijiImxndcDFqY4=";
34     })
35   ];
37   postPatch = ''
38     for file in oscrypto/_openssl/_lib{crypto,ssl}_c{ffi,types}.py; do
39       substituteInPlace $file \
40         --replace "get_library('crypto', 'libcrypto.dylib', '42')" "'${openssl.out}/lib/libcrypto${stdenv.hostPlatform.extensions.sharedLibrary}'" \
41         --replace "get_library('ssl', 'libssl', '44')" "'${openssl.out}/lib/libssl${stdenv.hostPlatform.extensions.sharedLibrary}'"
42     done
43   '';
45   propagatedBuildInputs = [ asn1crypto ];
47   nativeCheckInputs = [ pytestCheckHook ];
49   pythonImportsCheck = [ "oscrypto" ];
51   doCheck = !stdenv.hostPlatform.isDarwin;
53   disabledTests = [
54     # Tests require network access
55     "TLSTests"
56     "TrustListTests"
57   ];
59   meta = with lib; {
60     description = "Encryption library for Python";
61     homepage = "https://github.com/wbond/oscrypto";
62     license = licenses.mit;
63     maintainers = [ ];
64   };