From 321e8addd3a8f170ac517f77aace7c573ffc0bd1 Mon Sep 17 00:00:00 2001 From: Sanyam Khurana Date: Fri, 24 Feb 2023 00:41:49 +0530 Subject: [PATCH 1/3] fix(setup): Add twilio and nexmo as optional dependency --- setup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 722280d..dd4d6ad 100644 --- a/setup.py +++ b/setup.py @@ -22,13 +22,15 @@ install_requires=[ "django>=2.1.5", "djangorestframework>=3.9.0", - "PyJWT>=1.7.1", - "python-dotenv>=0.10.0", + "PyJWT>=2.6.0", + "python-dotenv>=0.21.1", "phonenumbers>=8.10.2", "django-phonenumber-field>=2.1.0", - "twilio>=6.21.0", - "nexmo>=2.4.0", ], + extras_require={ + 'twilio': ["twilio>=7.16.4"], + 'nexmo': ["nexmo>=2.5.2"], + }, classifiers=[ "Environment :: Web Environment", "Development Status :: 5 - Production/Stable", From b0dbd4c1ae9848b31a846ee0b478d18c1a0df485 Mon Sep 17 00:00:00 2001 From: Sanyam Khurana Date: Fri, 24 Feb 2023 01:01:31 +0530 Subject: [PATCH 2/3] add few more links --- setup.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index dd4d6ad..66ae34c 100644 --- a/setup.py +++ b/setup.py @@ -28,8 +28,16 @@ "django-phonenumber-field>=2.1.0", ], extras_require={ - 'twilio': ["twilio>=7.16.4"], - 'nexmo': ["nexmo>=2.5.2"], + "twilio": ["twilio"], + "nexmo": ["nexmo"], + "all": ["twilio", "nexmo"], + }, + project_urls={ + "Documentation": "#TBD", + "Changelog": "#TBD", + "Code": "https://github.com/CuriousLearner/django-phone-verify", + "Tracker": "https://github.com/CuriousLearner/django-phone-verify/issues", + "Funding": "#TBD" }, classifiers=[ "Environment :: Web Environment", From 4e35b523094286ab6c2f2a860fe57767f433b965 Mon Sep 17 00:00:00 2001 From: Sanyam Khurana Date: Mon, 14 Oct 2024 01:32:19 +0530 Subject: [PATCH 3/3] fix(backends): Add error message if dependency for BE not found --- phone_verify/backends/__init__.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/phone_verify/backends/__init__.py b/phone_verify/backends/__init__.py index bfe3acc..522fe97 100644 --- a/phone_verify/backends/__init__.py +++ b/phone_verify/backends/__init__.py @@ -12,11 +12,23 @@ def get_sms_backend(phone_number): if not backend: if settings.PHONE_VERIFICATION.get("BACKEND", None): - backend_import = settings.PHONE_VERIFICATION["BACKEND"] + backend_import_path = settings.PHONE_VERIFICATION["BACKEND"] else: raise ImproperlyConfigured( "Please specify BACKEND in PHONE_VERIFICATION within your settings" ) - backend_cls = import_string(backend_import) + try: + backend_cls = import_string(backend_import_path) + except ImportError as e: + if not any(provider in backend_import_path.lower() for provider in ['twilio', 'nexmo']): + # Error for custom backends + raise RuntimeError(f"Failed to import the specified backend: {backend_import_path}. Ensure the module is installed and properly configured.") from e + + # Extract the module name (e.g., 'twilio' or 'nexmo') for a more meaningful error message + dependency_name = backend_import_path.split(".")[-2] + + # Raise an error with the correct dependency name + raise RuntimeError(f"{dependency_name.capitalize()} backend is not installed. Please install '{dependency_name}' to use this provider.") from e + return backend_cls(**settings.PHONE_VERIFICATION["OPTIONS"])