Skip to content

Commit 4f1c2e8

Browse files
asheshvfrozencemetery
authored andcommitted
Support 32-bit Windows if using 32-bit Python
Signed-off-by: Ashesh Vashi <ashesh.vashi@enterprisedb.com> [rharwood@redhat.com: commit message, squash, minor style tweaks]
1 parent dfbf05a commit 4f1c2e8

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Diff for: gssapi/_win_config.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import os
1010
import shutil
11+
import sys
1112
import ctypes
1213

1314
#: Path to normal KfW installed bin folder
@@ -22,7 +23,10 @@
2223
def kfw_available():
2324
"""Return if the main GSSAPI DLL for KfW can be loaded"""
2425
try: # to load the main GSSAPI DLL
25-
ctypes.WinDLL('gssapi64.dll')
26+
if sys.maxsize > 2**32:
27+
ctypes.WinDLL('gssapi64.dll')
28+
else:
29+
ctypes.WinDLL('gssapi32.dll')
2630
except OSError: # DLL is not in PATH
2731
return False
2832
else: # DLL is in PATH, everything should work

Diff for: setup.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def get_output(*args, **kwargs):
3939
# get the compile and link args
4040
kc = "krb5-config"
4141
posix = os.name != 'nt'
42+
43+
# Per https://docs.python.org/3/library/platform.html#platform.architecture
44+
# this is the preferred way of determining "64-bitness".
45+
is64bit = sys.maxsize > 2**32
46+
4247
link_args, compile_args = [
4348
shlex.split(os.environ[e], posix=posix) if e in os.environ else None
4449
for e in ['GSSAPI_LINKER_ARGS', 'GSSAPI_COMPILER_ARGS']
@@ -97,7 +102,7 @@ def get_output(*args, **kwargs):
97102
link_args = ['-framework', 'GSS']
98103
elif winkrb_path:
99104
_libs = os.path.join(
100-
winkrb_path, 'lib', 'amd64' if sys.maxsize > 2 ** 32 else 'i386'
105+
winkrb_path, 'lib', 'amd64' if is64bit else 'i386'
101106
)
102107
link_args = (
103108
['-L%s' % _libs]
@@ -114,8 +119,9 @@ def get_output(*args, **kwargs):
114119
elif winkrb_path:
115120
compile_args = [
116121
'-I%s' % os.path.join(winkrb_path, 'include'),
117-
'-DMS_WIN64'
118122
]
123+
if is64bit:
124+
compile_args.append('-DMS_WIN64')
119125
elif os.environ.get('MINGW_PREFIX'):
120126
compile_args = ['-fPIC']
121127
else:
@@ -174,10 +180,7 @@ def get_output(*args, **kwargs):
174180
main_lib = os.environ.get('MINGW_PREFIX')+'/bin/libgss-3.dll'
175181
elif sys.platform == 'msys':
176182
# Plain msys, not running in MINGW_PREFIX. Try to get the lib from one
177-
_main_lib = (
178-
'/mingw%d/bin/libgss-3.dll'
179-
% (64 if sys.maxsize > 2 ** 32 else 32)
180-
)
183+
_main_lib = f'/mingw{64 if is64bit else 32}/bin/libgss-3.dll'
181184
if os.path.exists(_main_lib):
182185
main_lib = _main_lib
183186
os.environ['PATH'] += os.pathsep + os.path.dirname(main_lib)

0 commit comments

Comments
 (0)