@@ -37,6 +37,7 @@ def get_output(*args, **kwargs):
3737
3838
3939# get the compile and link args
40+ kc = "krb5-config"
4041posix = os .name != 'nt'
4142link_args , compile_args = [
4243 shlex .split (os .environ [e ], posix = posix ) if e in os .environ else None
@@ -71,6 +72,26 @@ def get_output(*args, **kwargs):
7172 except ValueError :
7273 cygwinccompiler .get_msvcr = lambda * a , ** kw : []
7374
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+
7495if link_args is None :
7596 if osx_has_gss_framework :
7697 link_args = ['-framework' , 'GSS' ]
@@ -85,7 +106,7 @@ def get_output(*args, **kwargs):
85106 elif os .environ .get ('MINGW_PREFIX' ):
86107 link_args = ['-lgss' ]
87108 else :
88- link_args = shlex .split (get_output ('krb5-config --libs gssapi' ))
109+ link_args = shlex .split (get_output (f" { kc } --libs gssapi" ))
89110
90111if compile_args is None :
91112 if osx_has_gss_framework :
@@ -98,14 +119,14 @@ def get_output(*args, **kwargs):
98119 elif os .environ .get ('MINGW_PREFIX' ):
99120 compile_args = ['-fPIC' ]
100121 else :
101- compile_args = shlex .split (get_output ('krb5-config --cflags gssapi' ))
122+ compile_args = shlex .split (get_output (f" { kc } --cflags gssapi" ))
102123
103124# add in the extra workarounds for different include structures
104125if winkrb_path :
105126 prefix = winkrb_path
106127else :
107128 try :
108- prefix = get_output ('krb5-config gssapi --prefix' )
129+ prefix = get_output (f" { kc } gssapi --prefix" )
109130 except Exception :
110131 print ("WARNING: couldn't find krb5-config; assuming prefix of %s"
111132 % str (sys .prefix ))
0 commit comments