Building Py2Exe from source

Discussion in 'Python' started by Kylotan, Dec 27, 2003.

  1. Kylotan

    Kylotan Guest

    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.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.

    If option 1 requires following these arduous-looking instructions:
    <http://starship.python.net/crew/mhammond/win32/BuildingExtensions.html>
    then I'd rather bypass that if at all possible. :) I only need to
    build standard executables, not DLLs, NT services, or anything to do
    with COM.

    Any help getting around this problem would be much appreciated.

    (Platform: Win98SE, Python 2.3.3.)

    --
    Ben Sizer
     
    Kylotan, Dec 27, 2003
    #1
    1. Advertising

  2. (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
     
    Thomas Heller, Dec 29, 2003
    #2
    1. Advertising

  3. Kylotan

    Kylotan Guest

    Thomas Heller <> wrote in message news:<>...
    > (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...


    One of my requirements is encryption of the pyc files. (I need -some-
    degree of basic protection against decompyle and the like.) The file
    in the archive needs to be encrypted and only decrypted when it comes
    to be imported. This looks like only being about 3 or 4 lines of extra
    C code (given a standalone encryption library) if put in the correct
    place.

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


    Sadly Python is my 2nd language, and these distutils scripts in
    general are possibly the most complex (or at least idiosyncratic) code
    that I've seen. I understand very little of it. :) And wouldn't know
    where to start altering it.

    > 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.


    Ok. I don't need to do this urgently, but Win98SE is going to be both
    a key development and deployment platform for me.

    --
    Ben Sizer
     
    Kylotan, Dec 31, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F. GEIGER
    Replies:
    0
    Views:
    944
    F. GEIGER
    Aug 16, 2004
  2. Intaek LIM

    building errors with py2exe

    Intaek LIM, Aug 26, 2004, in forum: Python
    Replies:
    1
    Views:
    366
    Peter Hansen
    Aug 26, 2004
  3. python
    Replies:
    3
    Views:
    1,866
    Simon Brunning
    May 22, 2006
  4. Chris Spencer

    Re: [Py2exe-users] py2exe 0.6.9 released

    Chris Spencer, Nov 17, 2008, in forum: Python
    Replies:
    3
    Views:
    594
    Pascal
    Dec 8, 2008
  5. Mark Hammond

    RE: [Py2exe-users] py2exe 0.6.9 released

    Mark Hammond, Nov 17, 2008, in forum: Python
    Replies:
    0
    Views:
    472
    Mark Hammond
    Nov 17, 2008
Loading...

Share This Page