FAQ
Hi All,
I am using py2exe to create a windows executable. I am curious if anyone
knows a way to automatically upgrade a py2exe windows executable while it is
running. Is that possible? If so how? If it isn't possible, what is the
next best thing? Also, if it is not available using py2exe is it available
in other languages/solutions your aware of?

-Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090302/a6f0246d/attachment.htm>

Search Discussions

  • Maxim Khitrov at Mar 3, 2009 at 2:56 am

    On Mon, Mar 2, 2009 at 9:18 PM, William Heath wrote:
    Hi All,
    I am using py2exe to create a windows executable. ?I am curious if anyone
    knows a way to automatically upgrade a py2exe windows executable while it is
    running. ?Is that possible? ?If so how? ?If it isn't possible, what is the
    next best thing? ?Also, if it is not available using py2exe is it available
    in other languages/solutions your aware of?
    -Tim
    I don't think there is a way to do this directly. The best thing that
    I can think of is to have your program to use the subprocess or
    multiprocessing modules to launch a second instance of itself when an
    update is required. The parent would pass the child any necessary data
    so the child could continue where the parent left off, have child
    acknowledge this transaction, and then the parent can exit. Depending
    on what your program is actually doing this may not be a reasonable
    solution. Look into os.pipe, multiprocessing.Queue, and
    subprocess.Popen.communicate. If you have pywin32 extension installed,
    win32event module contains a number of useful functions for things
    like creating inter-process events.

    - Max
  • Patrick Mullen at Mar 3, 2009 at 8:20 am

    On Mon, Mar 2, 2009 at 6:56 PM, Maxim Khitrov wrote:
    - Show quoted text -
    On Mon, Mar 2, 2009 at 9:18 PM, William Heath wrote:
    Hi All,
    I am using py2exe to create a windows executable. ?I am curious if anyone
    knows a way to automatically upgrade a py2exe windows executable while it is
    running. ?Is that possible? ?If so how? ?If it isn't possible, what is the
    next best thing? ?Also, if it is not available using py2exe is it available
    in other languages/solutions your aware of?
    -Tim
    Here's what I did, which works really well. The main script imports
    other python modules which do the real work of the program. It is
    only a few lines long and looks something like this:

    import main
    main.run()


    There is more stuff there, imports etc to help py2exe find everything,
    but that's the basic idea. Then, to upgrade the program, all I have
    to do is replace the modules which are in a subfolder. (And be
    careful to reload them, which has its own considerations).

    I do some wonky stuff in my build script to delete my main modules
    from library.zip since its easier to replace them outside of that, you
    could also use the skip-archive option to not use the .zip file at
    all.

    You really can't replace an exe itself while its running, I would
    avoid that as much as possible. Workarounds to do this are highly
    prone to error.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 3, '09 at 2:18a
activeMar 3, '09 at 8:20a
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase