Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
177 views
in Technique[技术] by (71.8m points)

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)

question from:https://stackoverflow.com/questions/65904313/python-py2exe-use-same-runtime-for-different-applications

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...