views:

572

answers:

2

Can anyone give me an example of how to use python's msilib standard library module to create a msi file from a custom python module?

For example, let's say I have a custom module called cool.py with the following code

class Cool(object):
    def print_cool(self):
        print "cool"

and I want to create an msi file using msilib that will install cool.py in python's site-packages directory.

How can I do that?

A: 

I think there is a misunderstanding: think of MS CAB Files as archives like .zip-Files. Now it is possible to put anything in such an archive, like your cool.py. But i think you mentioned that python source, since you want it executed, otherwise just use an archiver like zip, no need to use mslib.

If i am right then you first need to convert your script into an executable using something like py2exe or pyinstaller.

RSabet
+2  A: 

You need to write a distutils setup script for your module, then you can do

python setup.py bdist_msi

and an msi-installer will be created for your module.

See also http://docs.python.org/distutils/apiref.html#module-distutils.command.bdist_msi

theller