PyInstaller编译python3时使用的详细参数介绍

继续翻译中。。。。

The syntax of the pyinstaller command is:

pyinstaller [options] script [script ...] | specfile

//You may give a path to the script or spec file, for example
pyinstaller options... ~/myproject/source/myscript.py

//or, on Windows,
pyinstaller "C:Documents and Settingsprojectmyscript.spec"

生成什么:

-F, --onefile
创建一个捆绑好的可执行文件。Create a one-file bundled executable.

-D, --onedir
创建一个文件夹包含可执行包(默认)。Create a one-folder bundle containing an executable (default)

--specpath=DIR
指定存储生成的规范文件的文件夹。Folder to store the generated spec file (default: current directory)

-n NAME, --name=NAME
打包好的可执行文件的名字。Name to assign to the bundled app and spec file (default: first script's basename)

//form http://www.cnblogs.com/osfipin/

什么包,搜索位置

-p DIR, --paths=DIR
A path to search for imports (like using PYTHONPATH). Multiple paths are allowed, separated by ':', or use this option multiple times

--hidden-import=MODULENAME
Name an import not visible in the code of the script(s). This option can be used multiple times.

--additional-hooks-dir=HOOKSPATH
An additional path to search for hooks. This option can be used multiple times.

--runtime-hook=RUNTIME_HOOKS
Path to a custom runtime hook file. A runtime hook is code that is bundled with the executable and is executed before any other code or module to set up special features of the runtime environment. This option can be used multiple times.

--exclude-module=EXCLUDES
Optional module or package (his Python names,not path names) that will be ignored (as thoughit was not found).This option can be used multiple times.

--key=KEY
The key used to encrypt Python bytecode.

如何生成

-d, --debug
Tell the bootloader to issue progress messages while initializing and starting the bundled app. Used to diagnose problems with missing imports.

-s, --strip
在可执行程序和共享库应用一个符号表条(不建议用于Windows)。Apply a symbol-table strip to the executable and shared libs (not recommended for Windows) --noupx Do not use UPX even if it is available (works differently between Windows and *nix)

Windows和Mac OS X特定选项

-c, --console, --nowindowed
显示控制台窗口(默认)。Open a console window for standard i/o (default)

-w, --windowed, --noconsole
不显示控制台窗口(背景黑色的窗口)。Windows and Mac OS X: do not provide a console window for standard i/o. On Mac OS X this also triggers building an OS X .app bundle.This option is ignored in *NIX systems.

-i <FILE.ico or FILE.exe,ID or FILE.icns>, --icon=<FILE.ico or FILE.exe,ID or FILE.icns>
加入图标。FILE.ico: apply that icon to a Windows executable. FILE.exe,ID, extract the icon with ID from an exe. FILE.icns: apply the icon to the .app bundle on Mac OS X

Windows特定的选项

--version-file=FILE
add a version resource from FILE to the exe

-m <FILE or XML>, --manifest=<FILE or XML>
add manifest FILE or XML to the exe

-r <FILE[,TYPE[,NAME[,LANGUAGE]]]>, --resource=<FILE[,TYPE[,NAME[,LANGUAGE]]]>
Add or update a resource of the given type, name and language from FILE to a Windows executable. FILE can be a data file or an exe/dll. For data files, at least TYPE and NAME must be specified. LANGUAGE defaults to 0 or may be specified as wildcard * to update all resources of the given TYPE and NAME. For exe/dll files, all resources from FILE will be added/updated to the final executable if TYPE, NAME and LANGUAGE are omitted or specified as wildcard *.This option can be used multiple times.

--uac-admin
Using this option creates a Manifest which will request elevation upon application restart.

--uac-uiaccess
Using this option allows an elevated application to work with Remote Desktop.

Mac OS X的特定选项

--osx-bundle-identifier=BUNDLE_IDENTIFIER
Mac OS X .app bundle identifier is used as the default unique program name for code signing purposes. The usual form is a hierarchical name in reverse DNS notation. For example: com.mycompany.department.appname (default: first script's basename)

//osfipin来自 http://www.cnblogs.com/osfipin/

原文地址:https://www.cnblogs.com/osfipin/p/4752766.html