py2exe 0.6.1 released

Bengt Richter bokr at oz.net
Wed Sep 7 02:42:18 EDT 2005


On Tue, 06 Sep 2005 11:12:46 +0200, Thomas Heller <theller at python.net> wrote:

>"Giovanni Bajo" <noway at sorry.com> writes:
>
>> Thomas Heller wrote:
>>
>>>     * py2exe can now bundle binary extensions and dlls into the
>>>       library-archive or the executable itself.  This allows to
>>>       finally build real single-file executables.
>>>
>>>       The bundled dlls and pyds are loaded at runtime by some special
>>>       code that emulates the Windows LoadLibrary function - they are
>>>       never unpacked to the file system.
>>
>>
>> Cute!
>>
>> I tried it using the wx singlefile example, but unfortunately the resulting
>> executable segfaults at startup (using Python 2.3.3 on Windows 2000, with
>> latest wxWindows).
>
>Yes, I can reproduce that.  I'm still using wxPython 2.4.2.4 for Python
>2.3.5, and that combo works.  I have done a few tests, and wxPython
>2.5.1.5 also works, while 2.5.5.1 crashes.
>
>> How can I debug it?
>
>I'll assume that's a serious question.
>There is no simple answer.  First, the py2exe'd app responds to a
>PY2EXE_VERBOSE environment variable, if you set it to '1', the exe will
>reports imports (just as PYTHONVERBOSE does for python scripts).  Of
>course you have to change the sample so that it is built as console app
>to be able to see the messages.
If you have a place in the program where output should never happen
except when you would want a console window to see it in, you can
call AllocConsole [1] safely even in multiple such places, just before
the printing, and the first such call will create the console and hook
up stdout and stderr ready to print. Subsequent calls to AllocConsole
are effectively ignored, so all the output goes to the same console
no matter which code section executed first. IMO this should be
built into at least the windows wpython to trigger at the first
attempt at stdout or stderr output. There could be an option to
override that default and thus ignore stdout/stderr output, but I
think it would be a useful default. Plus it would tell people early
that they had usesless prints going in their wpython programs.

>
>Then, you can throw some additional prints into
>lib\site-packages\zipextimporter.py, to see what it does.
>
>I've done all this, and it seems it is crashing when trying to import
>_gdi.pyd.  Next would be to debug through _memimported.pyd, but I don't
>have a debug build of wxPython.
>
>That's all I can say now.
>
>I'll ask on the wxPython mailing list if they have an idea.
>
>Thomas

[1]

    The AllocConsole function allocates a new console for the
    calling process.

    BOOL AllocConsole(VOID)

    Parameters

    This function has no parameters.

    Return Value

    If the function succeeds, the return value is TRUE. If the
    function fails, the return value is FALSE. To get extended
    error information, call GetLastError.

    Remarks

    A process can only be associated with one console, so
    AllocConsole fails if the calling process already has a
    console. A process can use the FreeConsole function to
    detach itself from its current console, and then it can call
    AllocConsole to create a new console. If the calling process
    creates a child process, the child inherits the new console.
    AllocConsole also sets up standard input, standard output,
    and standard error handles for the new console. The standard
    input handle is a handle to the console's input buffer, and
    the standard output and standard error handles are handles
    to the console's screen buffer. To retrieve these handles,
    use the GetStdHandle function.

    This function is primarily used by graphics applications to
    create a console window. Graphics applications are
    initialized without a console. Console applications are
    normally initialized with a console, unless they are created
    as detached processes (by calling the CreateProcess function
    with the DETACHED_PROCESS flag).

    See Also

    CreateProcess, FreeConsole, GetStdHandle

Regards,
Bengt Richter



More information about the Python-list mailing list