15 Python scripts in one executable?

I've been dealing with solutions here and here all day:

How to combine multiple .py files into one .exe with Py2Exe

Packing multiple scripts in PyInstaller

but it’s not quite as I thought.

I have a program that I have been working on for the past 6 months, and I just got one of its functions from another developer who did his work in Python.

What I would like to do is use his scripts without forcing the user to download and install python.

The problem, as I see it, is that 1 python script calls the other 14 python scripts for various tasks.

So I ask, what is the best way to do this?

Is it possible to pack 15 scripts and all their dependencies in 1 exe, which I can name normally? or is there another way so that I can package the original script in exe and that exe can normally call .py scripts? or should I just say f 'it and enable the python installer with my setup file?

This is for Python 2.7.6 btw

And this is how the first script calls other scripts.

import printSub as ps
import arrayWorker as aw
import arrayBuilder as ab
import rootWorker as rw
import validateData as vd
etc...

If you were trying to include these scenarios, how would you do it?

thanks

+4
source share
2 answers

You can really use py2exe , it behaves the way you want.

See the answer to this question: How to combine several .py files into one .exe with Py2Exe

py2exe script exe ( python) zip ( pyc). DLL , , exe . , - exe - zip DLL.

py2exe exe . Exe script, python DLL. setup.py :

setup( 
  ...
  options = {         
    'py2exe' : {
        'compressed': 2, 
        'optimize': 2,
        'bundle_files': 1,
        'excludes': excludes}
        },                   
  zipfile=None, 
  console = ["your_main_script.py"],
  ...
)

:

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')
setup( 
  options = {         
    'py2exe' : {
        'compressed': 1, 
        'optimize': 2,
        'bundle_files': 3, #Options 1 & 2 do not work on a 64bit system
        'dist_dir': 'dist',  # Put .exe in dist/
        'xref': False,
        'skip_archive': False,
        'ascii': False,
        }
        },                   
  zipfile=None, 
  console = ['thisProject.py'],
)
+2

setup.py( ):

from distutils.core import setup
import py2exe

setup(console = ['multiple.py'])

:

  python setup.py py2exe

. - , .

0

Source: https://habr.com/ru/post/1523439/


All Articles