Python distutils

A guide to creating a simplistic .exe python package installer:

  1. Create a setup.py file in the directory above your package directory:
    MyPythonPackage
    setup.py
    
  2. Copy the following in setup.py:
    from distutils.core import setup
    import setuptools
    import sys
    
    setup(name='MyAmazingLibrary',
        version='0.1',
        description='My Amazing Library',
        author='My Name',
        url='http://code.google.com/p/MyAmazingLibrary/',
        packages=setuptools.find_packages('.'),
        package_dir = {'':'.'},
    )
  3. Open a command prompt in the directory containing the setup.py and execute
    python setup.py bdist_wininst
    
  4. Observe how the installer appears in the newly created dist directory.

Additional Notes

  • To specify that the installer is only for a specific Python install use the –target-version option with setup.py, eg:
    python setup.py bdist_wininst --target-version=2.5
    
  • Swap bdist_wininst to bdist_msi to create a Windows Installer for your python package.
 

Leave a Reply

Your email address will not be published. Required fields are marked *