Skip to content

Commit

Permalink
Configure Windows at import time to use the 32-bit kerbeors on a
Browse files Browse the repository at this point in the history
32-bit Python interpreter.
  • Loading branch information
asheshv committed May 25, 2021
1 parent dfbf05a commit eeb1b92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion gssapi/_win_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import os
import shutil
import sys
import ctypes

#: Path to normal KfW installed bin folder
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit eeb1b92

Please sign in to comment.