diff --git a/vertica_python/__init__.py b/vertica_python/__init__.py index 279af46b..25ed94b4 100644 --- a/vertica_python/__init__.py +++ b/vertica_python/__init__.py @@ -56,7 +56,9 @@ 'OperationalError', 'ProgrammingError'] # The version number of this library. + version_info = (1, 4, 0) + __version__ = '.'.join(map(str, version_info)) # The protocol version (3.16) implemented in this library. diff --git a/vertica_python/vertica/messages/frontend_messages/password.py b/vertica_python/vertica/messages/frontend_messages/password.py index f48d2684..80c437c8 100644 --- a/vertica_python/vertica/messages/frontend_messages/password.py +++ b/vertica_python/vertica/messages/frontend_messages/password.py @@ -42,8 +42,39 @@ from ..backend_messages.authentication import Authentication from ....compat import as_bytes -from . import crypt_windows as crypt - +try: + if os.name == 'nt': + # Windows-specific crypt module workaround + # Try using passlib or cryptography in place of 'crypt' on Windows + try: + from passlib.hash import sha256_crypt as crypt # Passlib as fallback + except ImportError: + try: + from cryptography.hazmat.primitives import hashes # Cryptography fallback + crypt = hashes # Note: hashes doesn't replace 'crypt', review usage + except ImportError: + raise ValueError( + "Neither 'passlib' nor 'cryptography' is available on Windows, " + "and the 'crypt' module is missing. " + "Please install one of these libraries or adapt the code to use a different hashing mechanism." + ) + else: + # Try importing cryptography as an alternative for non-Windows platforms + try: + from cryptography.hazmat.primitives import hashes + crypt = hashes # Note: hashes doesn't replace 'crypt', review usage + except ImportError: + # If cryptography isn't available, fallback to passlib + try: + from passlib.hash import sha256_crypt as crypt + except ImportError: + raise ValueError( + "Neither 'cryptography' nor 'passlib' is available, " + "and the 'crypt' module is missing. " + "Please install one of these libraries or adapt the code to use a different hashing mechanism." + ) +except ValueError as e: + raise ValueError(f"Error importing crypt module: {e}") from e class Password(BulkFrontendMessage): message_id = b'p'