@@ -39,6 +39,11 @@ def get_output(*args, **kwargs):
3939# get the compile and link args
4040kc = "krb5-config"
4141posix = 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+
4247link_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