Okay, I love what I can do with distutils in windows - i.e. create a binary distribution of a module/package/etc But I have a few questions: If I write a script to generate all the details of the distribution - files list, etc - how do I force the script to make it into a binary distro? Do I modify the arguement list passed to the script to 'fake' that it was called with this? Cos I may well just want to run a script and have that as default behaviour. I have seen that there is the facility to build extension modules into the distro by actually building them from source - is it recommended to do it this way - what about including pre-built extensions? I have tried adding them to the 'data_files' option and it seems to work - although by default they don't end up where I would expect. Has anyone else played with that? I know you can change the bitmap displayed during the install but can you change the icon that is displayed for the *.exe that is generated? Well I think that is enough questions for now... -- Phil "Requirements - what are they I just hack something together that does what I think they want" ;)
If I write a script to generate all the details of the distribution - files list, etc - how do I force the script to make it into a binary distro? Do I modify the arguement list passed to the script to 'fake' that it was called with this? Cos I may well just want to run a script and have that as default behaviour.
One of my scripts does: """ # Default and only distutils command is "py2exe" - save adding it to the # command line every single time. if len(sys.argv)==1 or \ (len(sys.argv)==2 and sys.argv[1] in ['-q', '-n']): sys.argv.append("py2exe") """ Hacky, but it works :) (and presumably you want 'bdist_wininst')
I have seen that there is the facility to build extension modules into the distro by actually building them from source - is it recommended to do it this way - what about including pre-built extensions? I have tried adding them to the 'data_files' option and it seems to work - although by default they don't end up where I would expect. Has anyone else played with that?
I think that by default, the "binary" distributions all ship binaries of your extension modules too. Thus, if your binary distribution has an extension module, the distribution is specific to a particular version of Python.
I know you can change the bitmap displayed during the install but can you change the icon that is displayed for the *.exe that is generated?
I dont think bdist_wininst does, but py2exe does. Mark
Mark, 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.
If I write a script to generate all the details of the distribution - files list, etc - how do I force the script to make it into a binary distro? Do I modify the arguement list passed to the script to 'fake' that it was called with this? Cos I may well just want to run a script and have that as default behaviour.
One of my scripts does:
""" # Default and only distutils command is "py2exe" - save adding it to the # command line every single time. if len(sys.argv)==1 or \ (len(sys.argv)==2 and sys.argv[1] in ['-q', '-n']): sys.argv.append("py2exe") """ Hacky, but it works :) (and presumably you want 'bdist_wininst')
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. 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.
I have seen that there is the facility to build extension modules into the distro by actually building them from source - is it recommended to do it this way - what about including pre-built extensions? I have tried adding them to the 'data_files' option and it seems to work - although by default they don't end up where I would expect. Has anyone else played with that?
I think that by default, the "binary" distributions all ship binaries of your extension modules too. Thus, if your binary distribution has an extension module, the distribution is specific to a particular version of Python.
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
I know you can change the bitmap displayed during the install but can you change the icon that is displayed for the *.exe that is generated?
I dont think bdist_wininst does, but py2exe does.
-- Phil "Requirements - what are they I just hack something together that does what I think they want" ;)
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 code.
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 extension. 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): install_data.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. Mark
"Phil Hornby" <phil.hornby@accutest.co.uk> writes:
Okay, I love what I can do with distutils in windows - i.e. create a binary distribution of a module/package/etc
But I have a few questions:
If I write a script to generate all the details of the distribution - files list, etc - how do I force the script to make it into a binary distro? Do I modify the arguement list passed to the script to 'fake' that it was called with this? Cos I may well just want to run a script and have that as default behaviour.
I have seen that there is the facility to build extension modules into the distro by actually building them from source - is it recommended to do it this way - what about including pre-built extensions? I have tried adding them to the 'data_files' option and it seems to work - although by default they don't end up where I would expect. Has anyone else played with that?
You can customize distutils to do *anything* you want by subclassing. The basic functionality, however, assumes you are distributing python modules, scripts, and extensions. And distutils actually is the easiest way imo to also *build* the extensions. IIRC, you can also use the borland compiler to build the extensions - see the output of 'python setup.py build_ext --help-compiler'.
I know you can change the bitmap displayed during the install but can you change the icon that is displayed for the *.exe that is generated?
You can change the icon of the Lib/site-packages/distutils/command/wininst.exe with any tool of your choice, *before* building the installer. Thomas
participants (3)
-
Mark Hammond
-
Phil Hornby
-
Thomas Heller