From 4cc61c3265e4e25034dc999e1234106f96ba5da7 Mon Sep 17 00:00:00 2001 From: "P. R. d. O" Date: Wed, 27 Apr 2022 16:10:27 -0600 Subject: [PATCH] python310Packages.proton-client: enable tests --- .../proton-client/0001-OpenSSL-path-fix.patch | 41 +++++++++++++++++++ .../python-modules/proton-client/default.nix | 26 ++++++++---- 2 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 pkgs/development/python-modules/proton-client/0001-OpenSSL-path-fix.patch diff --git a/pkgs/development/python-modules/proton-client/0001-OpenSSL-path-fix.patch b/pkgs/development/python-modules/proton-client/0001-OpenSSL-path-fix.patch new file mode 100644 index 000000000000..7e97b2da5d3f --- /dev/null +++ b/pkgs/development/python-modules/proton-client/0001-OpenSSL-path-fix.patch @@ -0,0 +1,41 @@ +From 48da17d61e38657dfb10f2ac642fd3e6a45ee607 Mon Sep 17 00:00:00 2001 +From: "P. R. d. O" +Date: Wed, 27 Apr 2022 14:29:53 -0600 +Subject: [PATCH] OpenSSL path fix + +--- + proton/srp/_ctsrp.py | 12 ++---------- + 1 file changed, 2 insertions(+), 10 deletions(-) + +diff --git a/proton/srp/_ctsrp.py b/proton/srp/_ctsrp.py +index e19f184..af359c5 100644 +--- a/proton/srp/_ctsrp.py ++++ b/proton/srp/_ctsrp.py +@@ -24,22 +24,14 @@ from .util import PM_VERSION, SRP_LEN_BYTES, SALT_LEN_BYTES, hash_password + dlls = list() + + platform = sys.platform +-if platform == 'darwin': +- dlls.append(ctypes.cdll.LoadLibrary('libssl.dylib')) +-elif 'win' in platform: ++if 'win' in platform: + for d in ('libeay32.dll', 'libssl32.dll', 'ssleay32.dll'): + try: + dlls.append(ctypes.cdll.LoadLibrary(d)) + except Exception: + pass + else: +- try: +- dlls.append(ctypes.cdll.LoadLibrary('libssl.so.10')) +- except OSError: +- try: +- dlls.append(ctypes.cdll.LoadLibrary('libssl.so.1.0.0')) +- except OSError: +- dlls.append(ctypes.cdll.LoadLibrary('libssl.so')) ++ dlls.append(ctypes.cdll.LoadLibrary('@openssl@/lib/libssl@ext@')) + + + class BIGNUM_Struct(ctypes.Structure): +-- +2.35.1 + diff --git a/pkgs/development/python-modules/proton-client/default.nix b/pkgs/development/python-modules/proton-client/default.nix index 01ebed36c72b..ca68c8cb54cf 100644 --- a/pkgs/development/python-modules/proton-client/default.nix +++ b/pkgs/development/python-modules/proton-client/default.nix @@ -1,10 +1,13 @@ { lib +, stdenv , buildPythonPackage , fetchFromGitHub , pythonOlder +, substituteAll , bcrypt , pyopenssl , python-gnupg +, pytestCheckHook , requests , openssl }: @@ -30,14 +33,21 @@ buildPythonPackage rec { buildInputs = [ openssl ]; - # This patch is supposed to indicate where to load OpenSSL library, - # but it is not working as intended. - #patchPhase = '' - # substituteInPlace proton/srp/_ctsrp.py --replace \ - # "ctypes.cdll.LoadLibrary('libssl.so.10')" "'${lib.getLib openssl}/lib/libssl.so'" - #''; - # Regarding the issue above, I'm disabling tests for now - doCheck = false; + patches = [ + # Patches library by fixing the openssl path + (substituteAll { + src = ./0001-OpenSSL-path-fix.patch; + openssl = openssl.out; + ext = stdenv.hostPlatform.extensions.sharedLibrary; + }) + ]; + + checkInputs = [ pytestCheckHook ]; + + disabledTests = [ + #ValueError: Invalid modulus + "test_modulus_verification" + ]; pythonImportsCheck = [ "proton" ];