diff --git a/gssapi/_win_config.py b/gssapi/_win_config.py index ccbdb259..c3147fcb 100644 --- a/gssapi/_win_config.py +++ b/gssapi/_win_config.py @@ -8,6 +8,7 @@ import os import shutil +import sys import ctypes #: Path to normal KfW installed bin folder @@ -17,12 +18,16 @@ ) #: Download location for KfW KFW_DL = "https://web.mit.edu/KERBEROS/dist" +is64bits = sys.maxsize > 2**32 def kfw_available(): """Return if the main GSSAPI DLL for KfW can be loaded""" try: # to load the main GSSAPI DLL - ctypes.WinDLL('gssapi64.dll') + if is64bits is True: + ctypes.WinDLL('gssapi64.dll') + else: + ctypes.WinDLL('gssapi32.dll') except OSError: # DLL is not in PATH return False else: # DLL is in PATH, everything should work diff --git a/setup.py b/setup.py index 37bef146..c4df3364 100755 --- a/setup.py +++ b/setup.py @@ -39,6 +39,14 @@ def get_output(*args, **kwargs): # get the compile and link args kc = "krb5-config" posix = os.name != 'nt' + +# According to the Python documentation, in order to get the '64-bitness' of +# the current interpreter, it is more reliable to query the sys.maxsize +# attribute: +# +# Reference: +# https://docs.python.org/3/library/platform.html#platform.architecture +is64bits = sys.maxsize > 2**32 link_args, compile_args = [ shlex.split(os.environ[e], posix=posix) if e in os.environ else None for e in ['GSSAPI_LINKER_ARGS', 'GSSAPI_COMPILER_ARGS'] @@ -114,8 +122,9 @@ def get_output(*args, **kwargs): elif winkrb_path: compile_args = [ '-I%s' % os.path.join(winkrb_path, 'include'), - '-DMS_WIN64' ] + if is64bits: + compile_args.push('-DMS_WIN64') elif os.environ.get('MINGW_PREFIX'): compile_args = ['-fPIC'] else: