Search code examples
pythonwxpythondistutilssetup.py

How to use setup.py to install a python application


I am having problems understanding how best to use distutils and setup.py to install my wxPython Python application.

Here are my requirements:

  • Installs under Windows, Linux, OS X (is this feasible, or should I be focusing on Linux, and distribute binaries for Windows and OS X?)
  • For Linux, installs the main script in /usr/bin/ and removes the .py extension so it can be evoked with # gooeypi
  • Installs all other files in the python library folder (or a subfolder?) so imports will work.

An additional question: where would the application install under Windows?

Last question: is my tree correct? Should my main executable be in the same folder as my other modules? Would this cause potential name collisions with other modules, especially with common names like util and pref?

Here is my tree:

gooeypi\ 
    ----gooeypi\
          ------gooeypy.pyw # main executable
          ------controller.py
          ------util.py 
          ------pref.py
          ------configspec.ini
    ----setup.py
    ----LICENSE
    ----MANIFEST.in
    ----README.txt

And my setup.py

$ cat setup.py
#!/usr/bin/env python

from distutils.core import setup

setup(name='GooeyPi',
    version='0.1',
    description='Cross-platform wxPython GUI front-end to PyInstaller',
    author='Pedram Navid',
    author_email='pedram.navid at gmail dot com',
    url='http://www.github.com/multiphrenic/GooeyPi',
    packages=['gooeypi'],
    scripts=['gooeypi/gooeypi.pyw'],
     )

Solution

  • To get automatic creation of platform-specific executables, you need to use setuptools on top of distutils: http://pythonhosted.org/setuptools/setuptools.html#automatic-script-creation

    Updated Link if the one above isn't working.