@@ -37,6 +37,7 @@ def get_output(*args, **kwargs):
37
37
38
38
39
39
# get the compile and link args
40
+ kc = "krb5-config"
40
41
posix = os .name != 'nt'
41
42
link_args , compile_args = [
42
43
shlex .split (os .environ [e ], posix = posix ) if e in os .environ else None
@@ -71,6 +72,26 @@ def get_output(*args, **kwargs):
71
72
except ValueError :
72
73
cygwinccompiler .get_msvcr = lambda * a , ** kw : []
73
74
75
+ if sys .platform .startswith ("freebsd" ):
76
+ # FreeBSD does $PATH backward, for our purposes. That is, the package
77
+ # manager's version of the software is in /usr/local, which is in PATH
78
+ # *after* the version in /usr. We prefer the package manager's version
79
+ # because the Heimdal in base is truly ancient, but this can be overridden
80
+ # - either in the "normal" fashion by putting something in PATH in front
81
+ # of it, or by removing /usr/local from PATH.
82
+
83
+ bins = []
84
+ for b in os .environ ["PATH" ].split (":" ):
85
+ p = f"{ b } /krb5-config"
86
+ if not os .path .exists (p ):
87
+ continue
88
+ bins .append (p )
89
+
90
+ if len (bins ) > 1 and bins [0 ] == "/usr/bin/krb5-config" and \
91
+ "/usr/local/bin/krb5-config" in bins :
92
+ kc = "/usr/local/bin/krb5-config"
93
+ print (f"Detected: { kc } " )
94
+
74
95
if link_args is None :
75
96
if osx_has_gss_framework :
76
97
link_args = ['-framework' , 'GSS' ]
@@ -85,7 +106,7 @@ def get_output(*args, **kwargs):
85
106
elif os .environ .get ('MINGW_PREFIX' ):
86
107
link_args = ['-lgss' ]
87
108
else :
88
- link_args = shlex .split (get_output ('krb5-config --libs gssapi' ))
109
+ link_args = shlex .split (get_output (f" { kc } --libs gssapi" ))
89
110
90
111
if compile_args is None :
91
112
if osx_has_gss_framework :
@@ -98,14 +119,14 @@ def get_output(*args, **kwargs):
98
119
elif os .environ .get ('MINGW_PREFIX' ):
99
120
compile_args = ['-fPIC' ]
100
121
else :
101
- compile_args = shlex .split (get_output ('krb5-config --cflags gssapi' ))
122
+ compile_args = shlex .split (get_output (f" { kc } --cflags gssapi" ))
102
123
103
124
# add in the extra workarounds for different include structures
104
125
if winkrb_path :
105
126
prefix = winkrb_path
106
127
else :
107
128
try :
108
- prefix = get_output ('krb5-config gssapi --prefix' )
129
+ prefix = get_output (f" { kc } gssapi --prefix" )
109
130
except Exception :
110
131
print ("WARNING: couldn't find krb5-config; assuming prefix of %s"
111
132
% str (sys .prefix ))
0 commit comments