There tools are based on same strategy.
- resolve dependencies in your app
- generate .pyc .pyo
- bundle them with python interpreter.
PyInstaller
How to produce target:
How to produce .spec file:
will produce exe_name.spec.
How to access Data Files from Manual. It is too much.
if you are using intaller, you can have data dir but end users may change them.
- Pros: you don't have to write your own setup.py
- Cons: it is tricky to access data files
How to produce target:
python Build.py exe_name.spec
How to produce .spec file:
python Makespec.py -w -F -n exe_name yourscript.py
will produce exe_name.spec.
- -w for window application, surpress console window to come up.
- -F for produce a single file deployment
- -n for specify exe filename.
How to access Data Files from Manual. It is too much.
import sys, carchive
this = carchive.CArchive(sys.executable)
data = this.extract('mystuff')[1]
if you are using intaller, you can have data dir but end users may change them.
py2exe
most widespread tool. To use, you have to write a setup.py file.
kw of setup: packages, package_dir, py_modules affect your exe (of cause), package_data does not. So need to use data_files instead. Make sure to specify zipfile=None, otherwise you'll have small exe with big .lzh usually this is not what you want.
then,
and you'll find exe in .dist
most widespread tool. To use, you have to write a setup.py file.
kw of setup: packages, package_dir, py_modules affect your exe (of cause), package_data does not. So need to use data_files instead. Make sure to specify zipfile=None, otherwise you'll have small exe with big .lzh usually this is not what you want.
from setuptools import setup, find_packages
import py2exe
import sys
sys.argv.append('py2exe')
setup(
name="blah",
version='alpha-0.1',
zip_safe=False,
description="blah",
long_description="""blah blah blah""",
url='http://www.py2exe.org',
license='python license',
author='AUTHOR',
author_email='email@email',
packages=find_packages('./src'),
package_dir={'':'./src'},
py_modules=['one'],
package_data={'.':['myjpeg.jpg'],
},
scripts=["your_script",],
#py2exe options
options={'py2exe':{'bundle_files':1}},
windows=[{'script':'your_script'},],
data_files=[('.',['myjpeg.jpg'], ),],
zipfile=None,
)
then,
python setup.py py2exe
and you'll find exe in .dist
py2app
How to produce target:
How to produce setup.py for py2app
Very easy to incluide resource. I guess it is because MacOS X provides application as a sort of directory.
How to produce target:
python setup.py py2app
How to produce setup.py for py2app
py2applet --make-setup yourscript.py -r your_resouce
Very easy to incluide resource. I guess it is because MacOS X provides application as a sort of directory.
0 件のコメント:
コメントを投稿