How do I use py2exe with paver?

200 Views Asked by At

I'm using paver to build my Python application, and I'd like to create an executable using py2exe. I've got the following in my pavement.py:

from paver.setuputils import setup
from distutils.core import setup
import py2exe

import paver
paver.setuputils.install_distutils_tasks()

... but when I run paver py2exe I get "Build failed: py2exe is not a Task". What am I doing wrong?

3

There are 3 best solutions below

1
On

From the tutorial, you just pass your "main" python script to the setup command:

from distutils.core import setup
import py2exe

setup(console=['hello.py'])

Have you tried building your execuable this way?

0
On

You are overwriting paver's setup with distutils one.

Also, calling paver.setuputils.install_distutils_tasks() is not needed; just call setup in same was as You do in setup.py.

0
On

I too am trying to use py2exe from paver. However, I ran into the problem described here and from that (and some other googling around) my conclusion is that the two aren't integrated and that the cleanest thing to do is to maintain a separate setup.py for py2exe and hope distutils2 improves things.

However, I would be very happy to be proven wrong..