[Distutils] Distutils windows binaries...

Mark Hammond mhammond at skippinet.com.au
Mon Feb 2 22:39:10 EST 2004

> Thanks for the code snippet I knew how to do it but wasn't
> sure if that was
> the only way to give the 'bdist_wininst' behaviour? Is there
> not a function
> interface that allows me to do it explicity within my code
> say by calling a
> different function than the basic setup() function?? The
> documentation on
> any of the other function seems to be all but non-existent.

Last time I looked at the code, no.  Use the source, luke ;)  I agree this
would be nice, and would not require much refactoring of distutils mainline

> The documentation seems to imply that you can specify *.c
> file for extension
> modules with some compiler details but that indicates a need
> to compile the
> module to me...there don't seem to be any options that allow
> you to indicate
> *.dll(or *.pyd) files.

Right, I see what you mean.  distutils generally wants you to specify the .c
file, and does expect to be able to build the .c file.  However, the binary
packages include only the compiled module.

> For example I am not sure if distutils supports
> Borland C++ Builder and I have several extensions written and
> compiled with
> it that I would like to package up. I am now looking at
> moving them across
> to MSVC which will mean a MAJOR code revamp but at present I
> don't want to
> re-compile the extension everytime I make a distro.

There are a number of potential problems you can face distributing modules
built with a different compiler; specifically, Python makes a number of
assumptions that the C runtime lib used by Python itself is the same as the

But assuming you know all that and understand the implications, the best
approach is to probably create your own subclass of install_data.  Your
finalize_options method can call the base class, then just copy your .pyd
in.  The win32all distutils script does:

class my_install_data(install_data):
     def finalize_options(self):
         ... # my custom stuff, referencing self.install_dir
dist = setup(name="pywin32",
             cmdclass = { 'install_data': my_install_data,

> I was just about to look at py2exe until I saw your other e-mail...doh
> nevermind...it would just be nice as when distributing a
> module putting an
> approriate icon on it would be useful...from a commercial
> point of view

For commercial apps, I believe that using py2exe + inno is a good way to go.
Via the py2exe project, we have the know-how to update the icon in the
executable, but noone has done it for distutils yet.


More information about the Distutils-SIG mailing list