[Distutils] Duelling SWIG patches

Thomas Heller thomas.heller@ion-tof.com
Tue, 27 Jun 2000 13:01:05 +0200


> On 26 June 2000, Thomas Heller said:
> > but this is of course nonsense. Swig is used to build
> > python-extensions, not exe-files. Sorry for that.
>
> Yeah, but I'd still like to know if 'link_executable()' works on
> Windows!  I think it'd be really cool if part of building Distutils on
> Windows was (optionally!) to compile your wininst stub, all using the
> Distutils compiler interface...
Yes, it works.
To illustrate: this is an excerpt of my setup.py for
win32all (building wininst.exe inside Distutils is reserved for
later):

class my_build_ext (build_ext):
    def run (self):
        build_ext.run (self)
        self.build_dlls()
        self.build_exes()

    def build_dlls (self):
        for target in dll_files:
            sources = target.sources
            ext_filename = os.path.join (self.build_lib,
                                         target.name + '.dll')

            if not (self.force or newer_group(sources, ext_filename,
'newer')):
                self.announce ("skipping '%s' (up-to-date)" %
                               target.name)
                return
            else:
                self.announce ("building '%s'" % target.name)

            objects = self.compiler.compile (target.sources,
                                             output_dir=self.build_temp,

include_dirs=target.include_dirs,
                                             debug=self.debug,

extra_postargs=target.extra_compile_args)

            self.compiler.link_shared_object(
                objects, ext_filename,
                libraries=target.libraries,
                library_dirs=target.library_dirs,
                extra_postargs=target.extra_args,
                debug=self.debug)


    def build_exes (self):
        for target in exe_files:
            sources = target.sources
            ext_filename = os.path.join (self.build_lib,
                                         target.name)

            if not (self.force or newer_group(sources, ext_filename +
'.exe', 'newer')):
                self.announce ("skipping '%s' (up-to-date)" %
                               target.name)
                return
            else:
                self.announce ("building '%s'" % target.name)

            extra_args = target.extra_compile_args
            objects = self.compiler.compile (sources,
                                             output_dir=self.build_temp,

include_dirs=target.include_dirs,
                                             debug=self.debug,
                                             extra_postargs=extra_args)

            extra_args = target.extra_link_args

            self.compiler.link_executable(
                objects, ext_filename,
                libraries=target.libraries,
                library_dirs=target.library_dirs,
                extra_postargs=extra_args,
                debug=self.debug)

> [about the MSVC compiler patches]
> Hey, waitasec: you're referring to "build/lib.win32/Release" -- but the
> code in front me of says
>
>     self.implib_dir = self.build_temp
>
> which to me eyes (scanning build_ext.py and build.py) resolves to
> "build/temp.win32", hence the Debug and Release directories are under
> build/temp.win32, not build/lib.win32.
>
Sorry, a simple typo. You are correct: What I meant is build/temp.win32.

Thomas