[ctypes-commit] ctypes setup.py,1.122.2.10,1.122.2.11
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-01-31 19:44:47
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14582 Modified Files: Tag: branch_1_0 setup.py Log Message: Integrated a patch from Hye-Shik Chang (perky). He wrote (http://mail.python.org/pipermail/python-dev/2006-January/060199.html): I did some work to make ctypes+libffi compacter and liberal. http://openlook.org/svnpublic/ctypes-compactffi/ (snv) I removed sources/gcc and put sources/libffi copied from gcc 4.0.2. And removed all automake-related build processes and integrated them info setup.py. There's still aclocal.m4 in sources/libffi. But it is just identical to libffi's acinclude.m4 which looks liberal. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.122.2.10 retrieving revision 1.122.2.11 diff -C2 -d -r1.122.2.10 -r1.122.2.11 *** setup.py 2 Jan 2006 19:07:50 -0000 1.122.2.10 --- setup.py 31 Jan 2006 19:44:35 -0000 1.122.2.11 *************** *** 10,14 **** """ ! LIBFFI_SOURCES='source/gcc/libffi' __version__ = "0.9.9.1" --- 10,14 ---- """ ! LIBFFI_SOURCES='source/libffi' __version__ = "0.9.9.1" *************** *** 123,150 **** build_ext.build_ext.finalize_options(self) ! # First build a static libffi library, then build the _ctypes extension. ! def run(self): ! self.build_libffi_static() ! build_ext.build_ext.run(self) ! def fix_extension(self, inst_dir): ! incdir = find_file_in_subdir(os.path.join(inst_dir, "include"), "ffi.h") ! if not incdir: return 0 ! libdir = find_file_in_subdir(os.path.join(inst_dir, "lib"), "libffi.a") or \ ! find_file_in_subdir(os.path.join(inst_dir, "lib64"), "libffi.a") ! if not libdir: return 0 ! incdir_2 = find_file_in_subdir(os.path.join(inst_dir, "lib"), "ffitarget.h") if not incdir_2: return 0 for ext in self.extensions: if ext.name == "_ctypes": ext.include_dirs.append(incdir) ext.include_dirs.append(incdir_2) ! ext.library_dirs.append(libdir) return 1 ! def build_libffi_static(self): if sys.platform == "win32": return --- 123,161 ---- build_ext.build_ext.finalize_options(self) ! # First configure a libffi library, then build the _ctypes extension. ! def build_extensions(self): ! self.configure_libffi() ! # Add .S (preprocessed assembly) to C compiler source extensions. ! self.compiler.src_extensions.append('.S') ! ! build_ext.build_ext.build_extensions(self) ! ! def fix_extension(self, ffi_dir): ! fficonfigfile = os.path.join(ffi_dir, 'fficonfig.py') ! if not os.path.exists(fficonfigfile): return 0 ! ! incdir = find_file_in_subdir(os.path.join(ffi_dir, "include"), "ffi.h") ! if not incdir: return 0 ! incdir_2 = find_file_in_subdir(ffi_dir, "fficonfig.h") if not incdir_2: return 0 + + fficonfig = {} + execfile(fficonfigfile, globals(), fficonfig) + for ext in self.extensions: if ext.name == "_ctypes": ext.include_dirs.append(incdir) ext.include_dirs.append(incdir_2) ! ext.sources.extend(fficonfig['ffi_sources']) ! if fficonfig['ffi_cflags'].strip(): ! ext.extra_compile_args.extend( ! fficonfig['ffi_cflags'].split()) return 1 ! def configure_libffi(self): if sys.platform == "win32": return *************** *** 157,187 **** build_dir = os.path.join(self.build_temp, 'libffi') - inst_dir = os.path.abspath(self.build_temp) ! if not self.force and self.fix_extension(inst_dir): return mkpath(build_dir) ! config_args = ["--disable-shared", ! "--enable-static", ! "--enable-multilib=no", ! "--prefix='%s'" % inst_dir, ! ] ! cmd = "cd %s && '%s/configure' %s && make install" \ % (build_dir, src_dir, " ".join(config_args)) ! print 'Building static FFI library:' print cmd - if sys.platform == "openbsd3": - os.environ["CFLAGS"] = "-fno-stack-protector" res = os.system(cmd) - if sys.platform == "openbsd3": - del os.environ["CFLAGS"] if res: print "Failed" sys.exit(res) ! assert self.fix_extension(inst_dir), "Could not find libffi after building it" # Since we mangle the build_temp dir, we must also do this in the clean command. --- 168,191 ---- build_dir = os.path.join(self.build_temp, 'libffi') ! if not self.force and self.fix_extension(build_dir): return mkpath(build_dir) ! 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" \ % (build_dir, src_dir, " ".join(config_args)) ! print 'Configuring static FFI library:' print cmd res = os.system(cmd) if res: print "Failed" sys.exit(res) ! assert self.fix_extension(build_dir), "Could not find libffi after building it" # Since we mangle the build_temp dir, we must also do this in the clean command. *************** *** 255,259 **** extensions = [Extension("_ctypes", - libraries=["ffi"], include_dirs=include_dirs, library_dirs=library_dirs, --- 259,262 ---- |