Skip to content

Commit 8e938d0

Browse files
committed
Make sure to use custom libraries when specified
Certain installations of Python will insert sysconfig 'LIBDIR' path before the `extra_link_args`. This means that if `extra_link_args` specifies a custom krb5 path, the linker will still use the system krb5, if it's in 'LIBDIR' (e.g. '/usr/lib'). This commit makes setup.py search the link args for '-L' entries, and insert them in `library_dirs` to that they get inserted *before* 'LIBDIR'.
1 parent 0bf60d1 commit 8e938d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

setup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def _get_output(*args, **kwargs):
6969
if os.path.exists(gssapi_ext_h):
7070
compile_args.append("-DHAS_GSSAPI_EXT_H")
7171

72+
# ensure that any specific directories are listed before any generic system
73+
# directories inserted by setuptools
74+
library_dirs = [arg[2:] for arg in link_args if arg.startswith('-L')]
75+
link_args = [arg for arg in link_args if not arg.startswith('-L')]
76+
7277
ENABLE_SUPPORT_DETECTION = \
7378
(os.environ.get('GSSAPI_SUPPORT_DETECT', 'true').lower() == 'true')
7479

@@ -109,6 +114,7 @@ def main_file(module):
109114
return Extension('gssapi.raw.%s' % module,
110115
extra_link_args=link_args,
111116
extra_compile_args=compile_args,
117+
library_dirs=library_dirs,
112118
sources=['gssapi/raw/%s.%s' % (module, SOURCE_EXT)])
113119

114120

@@ -127,11 +133,13 @@ def extension_file(module, canary):
127133
extra_link_args=link_args,
128134
extra_compile_args=compile_args,
129135
sources=[enum_ext_path],
136+
library_dirs=library_dirs,
130137
include_dirs=['gssapi/raw/']))
131138

132139
return Extension('gssapi.raw.ext_%s' % module,
133140
extra_link_args=link_args,
134141
extra_compile_args=compile_args,
142+
library_dirs=library_dirs,
135143
sources=['gssapi/raw/ext_%s.%s' % (module,
136144
SOURCE_EXT)])
137145

@@ -146,6 +154,7 @@ def gssapi_modules(lst):
146154
res.append(Extension('gssapi.raw.mech_%s' % mech,
147155
extra_link_args=link_args,
148156
extra_compile_args=compile_args,
157+
library_dirs=library_dirs,
149158
sources=['gssapi/raw/mech_%s.%s' % (mech,
150159
SOURCE_EXT)]))
151160

0 commit comments

Comments
 (0)