Search code examples
pythonpython-3.xpy2exe

Python Py2exe - use same runtime for different applications


I have two tkinter applications compiled via py2exe. This is the example of setup.py:

from distutils.core import setup
import py2exe


setup(
    name="my_app",
    version='1.0',
    author='Egor Wexler',
    windows=['main.py'],
    options={
        'py2exe': {
            'dist_dir': 'my_app',
            'compressed': False,
        }
    }
)

The file setup.py looks the same for both apps.

So when the app is compiled - it has its runtime in the same dir. Here - the executable is main.exe enter image description here

What I want is to have the shared runtime for different exe-files (from different projects but with the same virtual environment)

Is it possible to compile app the way that allows putting main.exe out of the folder? (And be able to make different exe-files utilizing the same runtime)


Solution

  • Found out how to do it:

    The two apps have to be put in the same folder (project) and then setup.py should look like this:

    from distutils.core import setup
    import py2exe
    
    
    setup(
        name="My apps",
        version='1.0',
        author='Egor Wexler',
        windows=['app1.py', 'app2.py', 'app3.py'],
        zipfile=None,
    
        options={
            'py2exe': {
                'dist_dir': 'build',
                'compressed': False,
                'bundle_files': 2,
            }
        }
    )
    

    Then all apps will be compiled to separate exe-files - app1.exe, app2.exe, app3.exe respectively and will use the shared runtime.