Skip to content

Commit 0bf60d1

Browse files
committed
Fix multiple -DHAS_GSSAPI_EXT_H compile flags
Previously, '-DHAS_GSSAPI_EXT_H' was printed multiple times for each extension, since the list of compile flags for each extension was actually just the global list. To correct this, we add '-DHAS_GSSAPI_EXT_H' once to the global list, instead of trying to add it to each extension's local list.
1 parent e98711a commit 0bf60d1

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

setup.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import print_function
33

44
from setuptools import setup
5-
from setuptools.command.build_ext import build_ext
65
from setuptools.command.sdist import sdist
76
from setuptools.extension import Extension
87
import platform
@@ -64,6 +63,12 @@ def _get_output(*args, **kwargs):
6463
link_args = link_args.split()
6564
compile_args = compile_args.split()
6665

66+
# add in the extra workarounds for different include structures
67+
prefix = get_output('krb5-config gssapi --prefix')
68+
gssapi_ext_h = os.path.join(prefix, 'include/gssapi/gssapi_ext.h')
69+
if os.path.exists(gssapi_ext_h):
70+
compile_args.append("-DHAS_GSSAPI_EXT_H")
71+
6772
ENABLE_SUPPORT_DETECTION = \
6873
(os.environ.get('GSSAPI_SUPPORT_DETECT', 'true').lower() == 'true')
6974

@@ -86,17 +91,6 @@ def _get_output(*args, **kwargs):
8691
GSSAPI_LIB = ctypes.CDLL(main_lib)
8792

8893

89-
class build_gssapi_ext(build_ext):
90-
def run(self):
91-
prefix = get_output('krb5-config gssapi --prefix')
92-
gssapi_ext_h = os.path.join(prefix, 'include/gssapi/gssapi_ext.h')
93-
if os.path.exists(gssapi_ext_h):
94-
for ext in self.extensions:
95-
ext.extra_compile_args.append("-DHAS_GSSAPI_EXT_H")
96-
97-
build_ext.run(self)
98-
99-
10094
# add in the flag that causes us not to compile from Cython when
10195
# installing from an sdist
10296
class sdist_gssapi(sdist):
@@ -192,7 +186,7 @@ def gssapi_modules(lst):
192186
'Topic :: Security',
193187
'Topic :: Software Development :: Libraries :: Python Modules'
194188
],
195-
cmdclass={'build_ext': build_gssapi_ext, 'sdist': sdist_gssapi},
189+
cmdclass={'sdist': sdist_gssapi},
196190
ext_modules=gssapi_modules([
197191
main_file('misc'),
198192
main_file('exceptions'),

0 commit comments

Comments
 (0)