Building Py2Exe from source

Thomas Heller theller at python.net
Mon Dec 29 17:15:47 EST 2003


kylotan at hotmail.com (Kylotan) writes:

> I need to be able to build Py2Exe from the source code as I am making
> a Windows executable where I wish to preprocess the modules before
> importing them.

Hm, is this really a good idea?  py2exe includes the .pyc (or .pyo)
files, not the sources itself.  Can't you preprocess them while building
the exe?  This way you would only have to hack python-code, not C code...

> It looks like I can do this by adding lines to
> Load_Module() in py2exe's start.c. However problem I have is that I
> can't build Py2Exe using the instructions provided. Using the
> designated command of "python setup.py install" I get this error:
>
>
>   Traceback (most recent call last):
>     File "setup.py", line 340, in ?
>       raise RuntimeError, msg
>   RuntimeError: PYWIN32DIR invalid.
>
>       To build py2exe from source, you must either:
>
>       - Download and build Mark Hammond's pywin32 source code
>         from http://starship.python.net/crew/mhammond, and set
>         the PYWIN32DIR variable to point to this directory
>
>       - or change this setup script to not build run_svc target,
>         then you will not be able to build Windows NT services
>         with py2exe.
>
>
> The main problem I encountered is that the 2nd option appears
> misleading: removing run_svc from the list of targets does no good as
> it still attempts to find some sort of "win32" directory before it
> even gets that far. Or maybe I'm missing something.

You *should* be able to hack the py2exe setup-script to do this, only
removing run_svc from the list is certainly not enough.

> Any help getting around this problem would be much appreciated.
>
> (Platform: Win98SE, Python 2.3.3.)

Normally I would recommend the upcoming py2exe 0.5 for this, although it
does not yet run on Win98, but I'm working on it.

Thomas




More information about the Python-list mailing list