--- setup.py.orig 2006-08-09 19:42:18.000000000 -0400 +++ setup.py 2006-09-22 23:06:59.711968075 -0400 @@ -180,10 +180,6 @@ def build_extension(self, ext): - if ext.name == '_ctypes': - if not self.configure_ctypes(ext): - return - try: build_ext.build_extension(self, ext) except (CCompilerError, DistutilsError), why: @@ -1032,9 +1028,6 @@ if (dl_inc is not None) and (platform not in ['atheos']): exts.append( Extension('dl', ['dlmodule.c']) ) - # Thomas Heller's _ctypes module - self.detect_ctypes(inc_dirs, lib_dirs) - # Platform-specific libraries if platform == 'linux2': # Linux-specific modules @@ -1305,118 +1298,6 @@ # *** Uncomment these for TOGL extension only: # -lGL -lGLU -lXext -lXmu \ - def configure_ctypes(self, ext): - if not self.use_system_libffi: - (srcdir,) = sysconfig.get_config_vars('srcdir') - ffi_builddir = os.path.join(self.build_temp, 'libffi') - ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', - '_ctypes', 'libffi')) - ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') - - from distutils.dep_util import newer_group - - config_sources = [os.path.join(ffi_srcdir, fname) - for fname in os.listdir(ffi_srcdir)] - if self.force or newer_group(config_sources, - ffi_configfile): - from distutils.dir_util import mkpath - mkpath(ffi_builddir) - config_args = [] - - # Pass empty CFLAGS because we'll just append the resulting - # CFLAGS to Python's; -g or -O2 is to be avoided. - cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ - % (ffi_builddir, ffi_srcdir, " ".join(config_args)) - - res = os.system(cmd) - if res or not os.path.exists(ffi_configfile): - print "Failed to configure _ctypes module" - return False - - fficonfig = {} - execfile(ffi_configfile, globals(), fficonfig) - ffi_srcdir = os.path.join(fficonfig['ffi_srcdir'], 'src') - - # Add .S (preprocessed assembly) to C compiler source extensions. - self.compiler.src_extensions.append('.S') - - include_dirs = [os.path.join(ffi_builddir, 'include'), - ffi_builddir, ffi_srcdir] - extra_compile_args = fficonfig['ffi_cflags'].split() - - ext.sources.extend(fficonfig['ffi_sources']) - ext.include_dirs.extend(include_dirs) - ext.extra_compile_args.extend(extra_compile_args) - return True - - def detect_ctypes(self, inc_dirs, lib_dirs): - self.use_system_libffi = False - include_dirs = [] - extra_compile_args = [] - extra_link_args = [] - sources = ['_ctypes/_ctypes.c', - '_ctypes/callbacks.c', - '_ctypes/callproc.c', - '_ctypes/stgdict.c', - '_ctypes/cfield.c', - '_ctypes/malloc_closure.c'] - depends = ['_ctypes/ctypes.h'] - - if sys.platform == 'darwin': - sources.append('_ctypes/darwin/dlfcn_simple.c') - include_dirs.append('_ctypes/darwin') -# XXX Is this still needed? -## extra_link_args.extend(['-read_only_relocs', 'warning']) - - elif sys.platform == 'sunos5': - # XXX This shouldn't be necessary; it appears that some - # of the assembler code is non-PIC (i.e. it has relocations - # when it shouldn't. The proper fix would be to rewrite - # the assembler code to be PIC. - # This only works with GCC; the Sun compiler likely refuses - # this option. If you want to compile ctypes with the Sun - # compiler, please research a proper solution, instead of - # finding some -z option for the Sun compiler. - extra_link_args.append('-mimpure-text') - - ext = Extension('_ctypes', - include_dirs=include_dirs, - extra_compile_args=extra_compile_args, - extra_link_args=extra_link_args, - libraries=[], - sources=sources, - depends=depends) - ext_test = Extension('_ctypes_test', - sources=['_ctypes/_ctypes_test.c']) - self.extensions.extend([ext, ext_test]) - - if not '--with-system-ffi' in sysconfig.get_config_var("CONFIG_ARGS"): - return - - ffi_inc = find_file('ffi.h', [], inc_dirs) - if ffi_inc is not None: - ffi_h = ffi_inc[0] + '/ffi.h' - fp = open(ffi_h) - while 1: - line = fp.readline() - if not line: - ffi_inc = None - break - if line.startswith('#define LIBFFI_H'): - break - ffi_lib = None - if ffi_inc is not None: - for lib_name in ('ffi_convenience', 'ffi_pic', 'ffi'): - if (self.compiler.find_library_file(lib_dirs, lib_name)): - ffi_lib = lib_name - break - - if ffi_inc and ffi_lib: - ext.include_dirs.extend(ffi_inc) - ext.libraries.append(ffi_lib) - self.use_system_libffi = True - - class PyBuildInstall(install): # Suppress the warning about installation into the lib_dynload # directory, which is not in sys.path when running Python during