Thank you for the quick response. Unfortunately, there are still a few difficulties I am having.
One issue is that I do not have an Extention in this package to piggyback the hello.c -> hello compilation onto. This compilation would also be performed for /every/ Extension given in ext_modules. If no extensions are given, the compilation never happens. If files that are not really python extensions are given, distutils crashes when trying to construct the egg because there is no real extension. Another issue for me is that the link_executable command seems to not include data the environment variable LDPATH, unlike link_shared_object and preprocess. This isn't a huge deal, but it meant that I had to manually insert the LDPATH flags into link_executable's extra_preargs If, instead of overriding build_ext, I try to do this outside of setup, a few issues get much harder. Without access to build_ext's self.build_temp and self.build_lib, how do I put the compiled binary into the right egg directory? Any further advice would be greatly appreciated! -Orion On 9/12/09 2:45 am, "Floris Bruynooghe" <floris.bruynoo...@gmail.com> wrote: > On Fri, Sep 11, 2009 at 01:15:07PM -0700, OB wrote: >> I am trying to get distutils to compile a single C script and install the >> binary to the same script directory as the entry point scripts that are >> generated for the python part of the module. I would like to use all the >> includes, CFLAGS, etc that are used when compiling extension modules, but >> this C script is not an extension. Is there a way to do this through setup, >> or do I need to use distutils.ccompiler.new_compiler() and try to hunt down >> CFLAGS, default libs, etc? > > (Ignoring the setuptools part of your question as I don't use that, > but I'm pretty sure it's very similar if not the same) > > If you don't want to create the compiler the easiest is to extend the > build_ext command: > > """ > from distutils.command.build_ext import build_ext > > class MyBuildExt(build_ext): > def run(self): > build_ext.run(self) > self.compiler.link_executable(['hello.c'], 'hello') > > setup(name='foo', > ... > cmdclass = {'build_ext': MyBuildExt}) > """ > > Here build_ext.run() will be setting all the include dirs, macros, > libs, rpaths etc into the compiler, which is what you want I think. > Obviously play around with the arguments to link_executable(), or you > could do it in 2 steps and create the object files first with > self.compiler.compile() if you want/need. > > If you don't want to extend build_ext then you've got to create the > compiler with distutils.ccompiler.new_compiler() and > distutils.sysconfig.customize_compiler(). Hunting down the settings > is a bit harder then, you'll be reading build_ext.finalize_options() > and build_ext.run() to figure this out. > > Regards > Floris _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig