ihatehippies 11 Junior Poster

Currently running python 2.7 on windows 7. I have an app created with wx python and compiled with py2exe. This app has an update utility that polls an update server at startup. If an update is found it downloads the new executable file (approx. 7mb) and makes the switch. It works well, but when I change 3 lines of code and publish an update the end user has to again download an entire 7+ mb file. I know that py2exe creates a zip archive containing the .pyo's and I would like to be able to add/remove/overwrite those .pyo files while leaving the rest of the .exe intact.

I've extracted the files using:

import zipfile, os
from traceback import format_exc as E
 

path = 'Tester.exe'
unzipped = 'unzip'


def Unzip():
    try:
        print 'extracting %s' % path
        x = zipfile.ZipFile(path)
        x.extractall(unzipped)
        print 'completed...'

    except:
      print E()


destination = 'test.exe'

def Zip():
    zip = zipfile.ZipFile(destination, 'w', zipfile.ZIP_DEFLATED)
    rootlen = len(unzipped) + 1
    for base, dirs, files in os.walk(unzipped):
        for file in files:
            fn = os.path.join(base, file)
            zip.write(fn, fn[rootlen:])

Obviously py2exe does more to the exe than just create an archive (including adding icon and manifest resources). Unzipping and then rezipping leaves out approximately 3 mb of data and expectedly does not return a working executable. Any ideas?