Nuitka打包

nuitka使用參考(windows)

官方文檔

安裝

安裝C編譯器

mingw64下載頁面

頁面拉到最下面咐容,目前最新版本為8.1.0,

x86_64-posix-sjlj

x86_64-posix-seh

x86_64-win32-sjlj

x86_64-win32-seh

i686-posix-sjlj

i686-posix-dwarf

i686-win32-sjlj

i686-win32-dwarf

附上版本區(qū)別詳解供參考

64位系統(tǒng)建議選擇x86_64-posix-sjlj

32位系統(tǒng)建議選擇i686-posix-sjlj

官方文檔中說要設(shè)置一下環(huán)境變量蚂维,實(shí)際使用過程中發(fā)現(xiàn)不設(shè)置也可以正常使用

安裝python

下載python,同樣按自己系統(tǒng)下載對(duì)應(yīng)的版本

安裝nuitka

python -m pip install nuitka

如果是anaconda

conda install -c conda-forge nuitka

簡(jiǎn)單測(cè)試

新建hello.py

def talk(message):

? ? return "Talk " + message



先直接用python運(yùn)行路狮,看看有沒有語法錯(cuò)誤

python hello.py

然后進(jìn)行構(gòu)建

nuitka? hello.py

命令結(jié)束后會(huì)生成一個(gè)exe虫啥,運(yùn)行exe和執(zhí)行上面第一條命令效果一樣。

復(fù)雜一點(diǎn)的測(cè)試奄妨,引用一個(gè)模塊

為了測(cè)試模塊引用涂籽,我們將上面的文件拆分成兩部分

新建mdl.py

def talk(message):

? ? return "Talk " + message

hello.py

from mdl import talk



def main():

? ? print( talk("Hello World"))


if __name__ == "__main__":

? ? main()

同樣按上面的順序進(jìn)行構(gòu)建

先直接用python運(yùn)行,看看有沒有語法錯(cuò)誤

python hello.py

然后進(jìn)行構(gòu)建

nuitka? hello.py

使用這條命令生成的exe可以正常運(yùn)行砸抛。

但如果將生成的exe拷貝到其他路徑執(zhí)行评雌,將會(huì)執(zhí)行失敗,提示找不到mdl模塊直焙,這是因?yàn)槭褂蒙鲜雒钌傻膃xe里面是并不包含上面的mdl模塊景东,于是在執(zhí)行該exe的時(shí)候,它會(huì)嘗試去調(diào)用mdl.py,如果找不到mdl.py奔誓,當(dāng)然就會(huì)提示找不到模塊斤吐,這和py文件的執(zhí)行原理是一樣的。

exe同級(jí)目錄下面會(huì)有一個(gè)python3x.dll文件厨喂,執(zhí)行exe文件時(shí)和措,如果需要調(diào)用外部模塊,需要這個(gè)文件的支持蜕煌。

關(guān)于python3x.dll

python3x.dll是與版本相對(duì)應(yīng)的派阱,如果是python3.8.3,那么就是python38.dll斜纪。實(shí)際上贫母,這個(gè)文件和python安裝目錄下面的python3x.dll是同一個(gè)文件(的拷貝)故响。python3x.dll相當(dāng)于一個(gè)運(yùn)行時(shí)(runtime),類似于javac颁独,或者微軟的framwork彩届,python代碼通過nuitka生成了二進(jìn)制代碼(exe或者pyd),但仍然通過python3x.dll保留了python的特性誓酒,比如調(diào)用一個(gè)python模塊

現(xiàn)在將整個(gè)目錄拷貝到其他路徑樟蠕,可以發(fā)現(xiàn)exe能夠正常執(zhí)行,因?yàn)榇藭r(shí)exe文件能夠通過python3x.dll找到mdl.py靠柑。

如果不想借助python3x.dll去調(diào)用模塊寨辩,就要將這個(gè)模塊打包進(jìn)exe

nuitka --follow-import-to=mdl hello.py

再次將生成的exe單獨(dú)拷貝到其他地方執(zhí)行,可以看到能夠正常運(yùn)行歼冰,此時(shí)不再需要拷貝python3x.dll和其他任何的文件靡狞。

打包模塊與follow import

上面的命令中使用了參數(shù)--follow-import-to,這個(gè)參數(shù)位于Control the recursion into imported modules這一部分隔嫡,這部分參數(shù)一共有五個(gè)

? ? --follow-stdlib, --recurse-stdlib

? ? ? ? ? ? ? ? ? ? ? ? Also descend into imported modules from standard

? ? ? ? ? ? ? ? ? ? ? ? library. This will increase the compilation time by a

? ? ? ? ? ? ? ? ? ? ? ? lot. Defaults to off.

? ? --nofollow-imports, --recurse-none

? ? ? ? ? ? ? ? ? ? ? ? When --recurse-none is used, do not descend into any

? ? ? ? ? ? ? ? ? ? ? ? imported modules at all, overrides all other recursion

? ? ? ? ? ? ? ? ? ? ? ? options. Defaults to off.

? ? --follow-imports, --recurse-all

? ? ? ? ? ? ? ? ? ? ? ? When --recurse-all is used, attempt to descend into

? ? ? ? ? ? ? ? ? ? ? ? all imported modules. Defaults to off.

? ? --follow-import-to=MODULE/PACKAGE, --recurse-to=MODULE/PACKAGE

? ? ? ? ? ? ? ? ? ? ? ? Recurse to that module, or if a package, to the whole

? ? ? ? ? ? ? ? ? ? ? ? package. Can be given multiple times. Default empty.

? ? --nofollow-import-to=MODULE/PACKAGE, --recurse-not-to=MODULE/PACKAGE

? ? ? ? ? ? ? ? ? ? ? ? Do not recurse to that module name, or if a package

? ? ? ? ? ? ? ? ? ? ? ? name, to the whole package in any case, overrides all

? ? ? ? ? ? ? ? ? ? ? ? other options. Can be given multiple times. Default

? ? ? ? ? ? ? ? ? ? ? ? empty.

這一部分參數(shù)可以說是nuitka的核心甸怕。nuitka能夠根據(jù)py文件中的import語句找到所有引用的庫,然后將這些庫文件打包進(jìn)二進(jìn)制文件中腮恩。找到import梢杭,然后follow,所以是follow import秸滴。所有被導(dǎo)入的庫可以看作一個(gè)列表武契,而這部分參數(shù)的作用就是讓用戶在這個(gè)列表中進(jìn)行選擇,只有被選中的部分會(huì)被打包進(jìn)exe

全選

--follow-imports, --recurse-all

不選

--nofollow-imports, --recurse-none

僅選擇標(biāo)準(zhǔn)庫

--follow-stdlib, --recurse-stdlib

僅選擇指定模塊/包

--follow-import-to=MODULE/PACKAGE, --recurse-to=MODULE/PACKAGE

不選擇指定模塊/包,這個(gè)選項(xiàng)會(huì)覆蓋其他遞歸選項(xiàng)荡含,也就是說最后用

--nofollow-import-to=MODULE/PACKAGE, --recurse-not-to=MODULE/PACKAGE

如果某些庫沒有被打包進(jìn)exe咒唆,程序仍會(huì)試圖通過python3x.dll去搜索路徑中查找這些庫,然后進(jìn)行調(diào)用释液,調(diào)用方式跟py文件一模一樣全释。

nuitka打包相對(duì)來說是比較耗費(fèi)時(shí)間的,特別是針對(duì)像pandas這樣的大家伙均澳,所以在最終發(fā)布之前恨溜,可以暫時(shí)不對(duì)這些庫進(jìn)行打包(--nofollow-imports),而是將這些庫手動(dòng)拷貝到搜索路徑中找前,比如exe同級(jí)目錄糟袁。只要能夠找到這些庫,程序就能正常運(yùn)行躺盛,否則會(huì)提示no module named xxx

注意:這部分參數(shù)僅僅能夠處理py或者pyc文件项戴,如果遇到pyd或者dll則會(huì)跳過

模塊搜索路徑

python程序如果引用了其他模塊(代碼中使用了import語句),就會(huì)到搜索路徑中去查找這些模塊槽惫,如果找不到就會(huì)提示

no module named xxx

搜索路徑有很多個(gè)周叮,而python使用環(huán)境變量sys.path管理這些路徑辩撑,可以在入口代碼最開頭使用

import sys print(sys.path)

查看運(yùn)行環(huán)境中的sys.path,看看缺失的庫是否存在于搜索路徑當(dāng)中仿耽。

發(fā)布一個(gè)程序

如果python程序中僅僅使用了一些自定義的模塊合冀,那么參數(shù)--follow-imports就足以達(dá)到發(fā)布的效果,一個(gè)exe外加一個(gè)python3x.dll就可以在任何電腦上運(yùn)行项贺,無論是否安裝python(當(dāng)然架構(gòu)要對(duì)應(yīng))君躺,然而實(shí)際情況往往比較復(fù)雜,稍微強(qiáng)大一點(diǎn)的程序都會(huì)調(diào)用一些第三方庫开缎,比如pyqt棕叫,numpy,這些模塊中調(diào)用了大量的pyd或者dll文件奕删。這個(gè)時(shí)候就需要使用參數(shù)--standalone俺泣。

參數(shù)--standalone默認(rèn)包含參數(shù)--follow-imports,即會(huì)嘗試對(duì)所有的引用到的庫都進(jìn)行打包完残,將這些庫中的py或者pyc打包進(jìn)exe伏钠,然后再將所依賴的二進(jìn)制文件(dll或者pyd)拷貝到exe所在文件夾。只要命令能夠執(zhí)行完成不出錯(cuò)坏怪,生成的exe就可以完全脫離python環(huán)境獨(dú)立運(yùn)行贝润。

depends.exe

在第一次使用--standalone時(shí),會(huì)提示安裝Dependency Walker铝宵,nuitka需要使用這個(gè)工具來解析所有的依賴,從而決定拷貝哪些文件(dll,pyd)到exe目錄华畏。命令進(jìn)行的過程中會(huì)自動(dòng)檢測(cè)該工具是否存在鹏秋,沒有的話會(huì)自動(dòng)提示進(jìn)行下載,網(wǎng)絡(luò)沒問題的時(shí)候直接回車或者輸入yes就行了亡笑,但是如果網(wǎng)絡(luò)狀況不佳侣夷,就需要提前手動(dòng)下載,否則命令會(huì)因此中斷仑乌。

具體步驟:手動(dòng)下載和系統(tǒng)相匹配的版本(32位或64位)百拓,解壓得到以下兩個(gè)文件

depends.exe depends.dll

然后放置到對(duì)應(yīng)的目錄 x86的路徑

C:\Users\Administrator\AppData\Local\Nuitka\Nuitka\x86\

X64的路徑

C:\Users\Administrator\AppData\Local\Nuitka\Nuitka\x86_64\

ps:我嘗試過將工具放在path中,沒有用晰甚,只能放在上面的路徑里面

可以通過參數(shù)--windows-dependency-tool=DEPENDENCY_TOOL將其修改為其他依賴解析工具衙传,比如pefile,但是不建議修改。參數(shù)--windows-dependency-tool=DEPENDENCY_TOOL僅限windows系統(tǒng)使用

參數(shù)--mingw64

實(shí)際上?--mingw64與--msvc=MSVC是一對(duì)孿生參數(shù)厕九,這兩個(gè)參數(shù)二選一蓖捶,用于指定編譯器,如果當(dāng)前環(huán)境既安裝了mingw64扁远,又安裝了msvc俊鱼,可以使用該參數(shù)選擇兼容性最好的編譯器,建議使用mingw64刻像。如果不存在上面兩種編譯器都存在的情況,就不需要顯式設(shè)置這個(gè)參數(shù)并闲,默認(rèn)會(huì)調(diào)用系統(tǒng)中能用的編譯器细睡。

參數(shù)plugin control

這部分參數(shù)用于設(shè)置對(duì)某些第三方庫或者python功能進(jìn)行支持,在使用--standalone時(shí)才會(huì)用到

如果程序中使用了pyqt或者pyside帝火,那么

--plugin-enable=qt-plugins

如果程序中使用了numpy, scipy, pandas, matplotlib溜徙,那么

--plugin-enable=numpy

如果使用了這些庫或功能,但是忘了進(jìn)行插件參數(shù)設(shè)置购公,命令運(yùn)行過程中會(huì)以紅字今天提醒萌京,按照提醒對(duì)命令進(jìn)行調(diào)整即可

如果有多個(gè)插件需要啟用

--plugin-enable=numpy? --plugin-enable=qt-plugins? --plugin-enable=tensorflow

可以使用?nuitka --plugin-list查看可用的插件

C:\Users\Administrator\Desktop\a>nuitka? --plugin-list

? ? ? ? The following optional standard plugins are available in Nuitka

--------------------------------------------------------------------------------

data-files

dill-compat

enum-compat

eventlet? ? ? ? ? Required by the eventlet package

gevent? ? ? ? ? ? Required by the gevent package

implicit-imports

multiprocessing? Required by Python's multiprocessing module

numpy? ? ? ? ? ? Required for numpy, scipy, pandas, matplotlib, etc.

pbr-compat

pmw-freezer? ? ? Required by the Pmw package

pylint-warnings? Support PyLint / PyDev linting source markers

qt-plugins? ? ? ? Required by the PyQt and PySide packages

tensorflow? ? ? ? Required by the tensorflow package

tk-inter? ? ? ? ? Required by Python's Tk modules

torch? ? ? ? ? ? Required by the torch / torchvision packages

參數(shù)Output choices

-o FILENAME

指定生成的可執(zhí)行文件的文件名,但是生成pyd的時(shí)候無法使用宏浩,也就是在使用--module的時(shí)候無法為pyd文件指定一個(gè)其他的文件名

--output-dir=DIRECTORY

指定打包好的文件存放的目錄知残,默認(rèn)為當(dāng)前目錄

--remove-output

使用nuitka進(jìn)行打包的過程中,會(huì)生成一個(gè)用于build的中間臨時(shí)目錄比庄,若可以使用該參數(shù)求妹,命令完成后會(huì)自動(dòng)刪除build目錄

--no-pyi-file

不生成pyi文件。pyi文件主要用于生成pyd文件時(shí)進(jìn)行隱式import的檢測(cè)

參數(shù)--show-progress 和--show-scons

用來顯示詳細(xì)打包過程佳窑,看得懂的話就加上吧制恍,這部分還有幾個(gè)參數(shù)幽告,感興趣的可以試試

? ? --show-scons? ? ? ? Operate Scons in non-quiet mode, showing the executed

? ? ? ? ? ? ? ? ? ? ? ? commands. Defaults to off.

? ? --show-progress? ? Provide progress information and statistics. Defaults

? ? ? ? ? ? ? ? ? ? ? ? to off.

? ? --show-memory? ? ? Provide memory information and statistics. Defaults to

? ? ? ? ? ? ? ? ? ? ? ? off.

? ? --show-modules? ? ? Provide a final summary on included modules. Defaults

? ? ? ? ? ? ? ? ? ? ? ? to off.

? ? --verbose? ? ? ? ? Output details of actions taken, esp. in

? ? ? ? ? ? ? ? ? ? ? ? optimizations. Can become a lot. Defaults to off.

數(shù) --windows-disable-console

禁用終端窗口韧掩,當(dāng)程序有一個(gè)圖形化界面的時(shí)候經(jīng)常用到,僅限windows系統(tǒng)

參數(shù) --windows-icon=ICON_PATH

設(shè)定程序的圖標(biāo)铅乡,僅限windows系統(tǒng)

----------------------------------------------------------- 深水區(qū)警告 --------------------------------------------------------------------

對(duì)反射的支持

python的反射機(jī)制溉委,簡(jiǎn)而言之鹃唯,就是可以通過字符串,動(dòng)態(tài)調(diào)用一些庫或者模塊瓣喊,諸如根據(jù)用戶的輸入調(diào)用插件等坡慌。

pack_name=input("input the package name:")

pack=__import__(pack_name)

上面這種情況,pack到底是哪個(gè)庫藻三,完全依賴于用戶輸入洪橘,nuitka沒法利用follow import這部分參數(shù)確定可能會(huì)被用到的庫。這種情況下可以不對(duì)這些庫進(jìn)行打包棵帽,那么打包好的exe只要在搜索路徑中能夠找到這些庫熄求,程序依然可以正常運(yùn)行。

但如果希望能夠?qū)⑦@些模塊打包為二進(jìn)制(exe或者pyd)岖寞,那么就要用到--include這部分參數(shù)

nuitka --follow-imports --include-package=testPackage mx.py

nuitka就會(huì)將這個(gè)package強(qiáng)行打包進(jìn)exe抡四,如果運(yùn)行的時(shí)需要進(jìn)行調(diào)用,程序就會(huì)在exe里面進(jìn)行尋找,看看有沒有這個(gè)package

include部分有四個(gè)具體的參數(shù)

指定一個(gè)package

--include-package=PACKAGE

指定一個(gè)module

--include-module=MODULE

指定一個(gè)目錄指巡,里面包含的所有包/模塊都會(huì)被打包(覆蓋其他遞歸選項(xiàng))

--include-plugin-directory=MODULE/PACKAGE

與pattern匹配的所有文件都會(huì)被打包(覆蓋其他遞歸選項(xiàng))

--include-plugin-files=PATTERN

使用參數(shù)--module打包生成pyd文件

使用--module參數(shù)淑履,將包/模塊打包為二進(jìn)制的pyd文件。module在這里可能會(huì)有點(diǎn)歧義藻雪,實(shí)際上借助--include參數(shù)秘噪,對(duì)于包/模塊/目錄(package/module/directory),都能打包為pyd勉耀。

打包一個(gè)package

nuitka --module --include-package=PACKAGE? PACKAGE?

打包一個(gè)module

nuitka --module --include-module=MODULE? ? MODULE

打包一個(gè)目錄

nuitka --module --include-plugin-directory=DIRECTORY? ? DIRECTORY

打包一堆零散文件指煎,與pattern匹配的所有文件都會(huì)被打包

nuitka --module --include-plugin-files=PATTERN? ? mods

打包pyd文件,必須借助--include參數(shù),這是因?yàn)榇虬黳yd的時(shí)候沒有入口文件便斥,所以就沒有import可以follow至壤,因此就必須要用到include對(duì)整個(gè)包進(jìn)行指定,否則打包出來的pyd文件里面不會(huì)有任何的內(nèi)容枢纠,引用這個(gè)pyd文件會(huì)提示找不到模塊

ps:打包pyd過程中如果出現(xiàn)類似警告提示

Nuitka:WARNING:Recursed to package 'TestPackage' at 'C:\Users\Administrator\Desktop\a\TestPackage' twice.

作者說不用管像街,原話如下

I think this one is actually described in the user manual.

We compile the filename you give as a module, even if it is a package, giving an empty package. Then you get to force inclusion of a whole module, which makes it see the top level twice, ignoring it, which triggers the warning.

常見錯(cuò)誤

(逐漸添加)

**ImportError: DLL load failed while importing xxxxx: %1 is not a valid Win32 application.**

加載pyd模塊時(shí)發(fā)生

原因:vscode沒有正確初始化

解決方法:直接在終端中運(yùn)行python

編譯模塊時(shí)候發(fā)生

ImportError: dynamic module does not define module export function (PyInit_TestPackage2)

原因:使用參數(shù)--module編譯出來的pyd文件,不能更改文件名

處理機(jī)制晋渺。


編譯過程需聯(lián)網(wǎng)添加部份組件镰绎,建議掛上梯子,網(wǎng)址可能被墻掉的木西,編譯過程大概率卡在下載

winlibs-x86_64-posix-seh-gcc-11.3.0-llvm-14.0.3-mingw-w64msvcrt-10.0.0-r3.zip

組件畴栖,復(fù)制該網(wǎng)址自行下載提示無效的,需自行下載

下載

下載后參考cmd里面提示的路徑把壓縮包里的目錄提取到類擬

Nuitka\Nuitka\Cache\downloads\gcc\x86_64\11.3.0-14.0.3-10.0.0-msvcrt-r3

這樣的路徑下八千,然后強(qiáng)行關(guān)掉cmd再重新編譯吗讶,除這個(gè)外其它的組件都能順利下載,編譯后py文件同級(jí)目錄下多了兩個(gè)目錄恋捆,其中帶dist里的exe就是執(zhí)行文件关翎,把該目錄復(fù)制就可以獨(dú)立使用exe文件了。


nuitka參數(shù)列表

輸入nuitka鸠信,回車之后會(huì)顯示nuitka的參數(shù)列表

Usage: __main__.py [--module] [--run] [options] main_module.py

Options:

? --version? ? ? ? ? ? show program's version number and exit

? -h, --help? ? ? ? ? ? show this help message and exit

? --module? ? ? ? ? ? ? Create an extension module executable instead of a

? ? ? ? ? ? ? ? ? ? ? ? program. Defaults to off.

? --standalone? ? ? ? ? Enable standalone mode in build. This allows you to

? ? ? ? ? ? ? ? ? ? ? ? transfer the created binary to other machines without

? ? ? ? ? ? ? ? ? ? ? ? it relying on an existing Python installation. It

? ? ? ? ? ? ? ? ? ? ? ? implies these option: "--recurse-all". You may also

? ? ? ? ? ? ? ? ? ? ? ? want to use "--python-flag=no_site" to avoid the

? ? ? ? ? ? ? ? ? ? ? ? "site.py" module, which can save a lot of code

? ? ? ? ? ? ? ? ? ? ? ? dependencies. Defaults to off.

? --python-arch=PYTHON_ARCH

? ? ? ? ? ? ? ? ? ? ? ? Architecture of Python to use. One of "x86" or

? ? ? ? ? ? ? ? ? ? ? ? "x86_64". Defaults to what you run Nuitka with

? ? ? ? ? ? ? ? ? ? ? ? (currently "x86_64").

? --python-debug? ? ? ? Use debug version or not. Default uses what you are

? ? ? ? ? ? ? ? ? ? ? ? using to run Nuitka, most likely a non-debug version.

? --python-flag=PYTHON_FLAGS

? ? ? ? ? ? ? ? ? ? ? ? Python flags to use. Default uses what you are using

? ? ? ? ? ? ? ? ? ? ? ? to run Nuitka, this enforces a specific mode. These

? ? ? ? ? ? ? ? ? ? ? ? are options that also exist to standard Python

? ? ? ? ? ? ? ? ? ? ? ? executable. Currently supported: "-S" (alias

? ? ? ? ? ? ? ? ? ? ? ? "nosite"), "static_hashes" (do not use hash

? ? ? ? ? ? ? ? ? ? ? ? randomization), "no_warnings" (do not give Python

? ? ? ? ? ? ? ? ? ? ? ? runtime warnings), "-O" (alias "noasserts"). Default

? ? ? ? ? ? ? ? ? ? ? ? empty.

? --python-for-scons=PYTHON_SCONS

? ? ? ? ? ? ? ? ? ? ? ? If using Python3.3 or Python3.4, provide the path of a

? ? ? ? ? ? ? ? ? ? ? ? Python binary to use for Scons. Otherwise Nuitka can

? ? ? ? ? ? ? ? ? ? ? ? use what you run Nuitka with or a "scons" binary that

? ? ? ? ? ? ? ? ? ? ? ? is found in PATH, or a Python installation from

? ? ? ? ? ? ? ? ? ? ? ? Windows registry.

? --warn-implicit-exceptions

? ? ? ? ? ? ? ? ? ? ? ? Enable warnings for implicit exceptions detected at

? ? ? ? ? ? ? ? ? ? ? ? compile time.

? --warn-unusual-code? Enable warnings for unusual code detected at compile

? ? ? ? ? ? ? ? ? ? ? ? time.

? --assume-yes-for-downloads

? ? ? ? ? ? ? ? ? ? ? ? Allow Nuitka to download code if necessary, e.g.

? ? ? ? ? ? ? ? ? ? ? ? dependency walker on Windows.

? Control the inclusion of modules and packages:

? ? --include-package=PACKAGE

? ? ? ? ? ? ? ? ? ? ? ? Include a whole package. Give as a Python namespace,

? ? ? ? ? ? ? ? ? ? ? ? e.g. ``some_package.sub_package`` and Nuitka will then

? ? ? ? ? ? ? ? ? ? ? ? find it and include it and all the modules found below

? ? ? ? ? ? ? ? ? ? ? ? that disk location in the binary or extension module

? ? ? ? ? ? ? ? ? ? ? ? it creates, and make it available for import by the

? ? ? ? ? ? ? ? ? ? ? ? code. Default empty.

? ? --include-module=MODULE

? ? ? ? ? ? ? ? ? ? ? ? Include a single module. Give as a Python namespace,

? ? ? ? ? ? ? ? ? ? ? ? e.g. ``some_package.some_module`` and Nuitka will then

? ? ? ? ? ? ? ? ? ? ? ? find it and include it in the binary or extension

? ? ? ? ? ? ? ? ? ? ? ? module it creates, and make it available for import by

? ? ? ? ? ? ? ? ? ? ? ? the code. Default empty.

? ? --include-plugin-directory=MODULE/PACKAGE

? ? ? ? ? ? ? ? ? ? ? ? Include the content of that directory, no matter if

? ? ? ? ? ? ? ? ? ? ? ? it's used by the given main program in a visible form.

? ? ? ? ? ? ? ? ? ? ? ? Overrides all other recursion options. Can be given

? ? ? ? ? ? ? ? ? ? ? ? multiple times. Default empty.

? ? --include-plugin-files=PATTERN

? ? ? ? ? ? ? ? ? ? ? ? Include into files matching the PATTERN. Overrides all

? ? ? ? ? ? ? ? ? ? ? ? recursion other options. Can be given multiple times.

? ? ? ? ? ? ? ? ? ? ? ? Default empty.

? Control the recursion into imported modules:

? ? --follow-stdlib, --recurse-stdlib

? ? ? ? ? ? ? ? ? ? ? ? Also descend into imported modules from standard

? ? ? ? ? ? ? ? ? ? ? ? library. This will increase the compilation time by a

? ? ? ? ? ? ? ? ? ? ? ? lot. Defaults to off.

? ? --nofollow-imports, --recurse-none

? ? ? ? ? ? ? ? ? ? ? ? When --recurse-none is used, do not descend into any

? ? ? ? ? ? ? ? ? ? ? ? imported modules at all, overrides all other recursion

? ? ? ? ? ? ? ? ? ? ? ? options. Defaults to off.

? ? --follow-imports, --recurse-all

? ? ? ? ? ? ? ? ? ? ? ? When --recurse-all is used, attempt to descend into

? ? ? ? ? ? ? ? ? ? ? ? all imported modules. Defaults to off.

? ? --follow-import-to=MODULE/PACKAGE, --recurse-to=MODULE/PACKAGE

? ? ? ? ? ? ? ? ? ? ? ? Recurse to that module, or if a package, to the whole

? ? ? ? ? ? ? ? ? ? ? ? package. Can be given multiple times. Default empty.

? ? --nofollow-import-to=MODULE/PACKAGE, --recurse-not-to=MODULE/PACKAGE

? ? ? ? ? ? ? ? ? ? ? ? Do not recurse to that module name, or if a package

? ? ? ? ? ? ? ? ? ? ? ? name, to the whole package in any case, overrides all

? ? ? ? ? ? ? ? ? ? ? ? other options. Can be given multiple times. Default

? ? ? ? ? ? ? ? ? ? ? ? empty.

? Immediate execution after compilation:

? ? --run? ? ? ? ? ? ? Execute immediately the created binary (or import the

? ? ? ? ? ? ? ? ? ? ? ? compiled module). Defaults to off.

? ? --debugger, --gdb? Execute inside "gdb" to automatically get a stack

? ? ? ? ? ? ? ? ? ? ? ? trace. Defaults to off.

? ? --execute-with-pythonpath

? ? ? ? ? ? ? ? ? ? ? ? When immediately executing the created binary

? ? ? ? ? ? ? ? ? ? ? ? (--execute), don't reset PYTHONPATH. When all modules

? ? ? ? ? ? ? ? ? ? ? ? are successfully included, you ought to not need

? ? ? ? ? ? ? ? ? ? ? ? PYTHONPATH anymore.

? Dump options for internal tree:

? ? --xml? ? ? ? ? ? ? Dump the final result of optimization as XML, then

? ? ? ? ? ? ? ? ? ? ? ? exit.

? Code generation choices:

? ? --full-compat? ? ? Enforce absolute compatibility with CPython. Do not

? ? ? ? ? ? ? ? ? ? ? ? even allow minor deviations from CPython behavior,

? ? ? ? ? ? ? ? ? ? ? ? e.g. not having better tracebacks or exception

? ? ? ? ? ? ? ? ? ? ? ? messages which are not really incompatible, but only

? ? ? ? ? ? ? ? ? ? ? ? different. This is intended for tests only and should

? ? ? ? ? ? ? ? ? ? ? ? not be used for normal use.

? ? --file-reference-choice=FILE_REFERENCE_MODE

? ? ? ? ? ? ? ? ? ? ? ? Select what value "__file__" is going to be. With

? ? ? ? ? ? ? ? ? ? ? ? "runtime" (default for standalone binary mode and

? ? ? ? ? ? ? ? ? ? ? ? module mode), the created binaries and modules, use

? ? ? ? ? ? ? ? ? ? ? ? the location of themselves to deduct the value of

? ? ? ? ? ? ? ? ? ? ? ? "__file__". Included packages pretend to be in

? ? ? ? ? ? ? ? ? ? ? ? directories below that location. This allows you to

? ? ? ? ? ? ? ? ? ? ? ? include data files in deployments. If you merely seek

? ? ? ? ? ? ? ? ? ? ? ? acceleration, it's better for you to use the

? ? ? ? ? ? ? ? ? ? ? ? "original" value, where the source files location will

? ? ? ? ? ? ? ? ? ? ? ? be used. With "frozen" a notation "<frozen

? ? ? ? ? ? ? ? ? ? ? ? module_name>" is used. For compatibility reasons, the

? ? ? ? ? ? ? ? ? ? ? ? "__file__" value will always have ".py" suffix

? ? ? ? ? ? ? ? ? ? ? ? independent of what it really is.

? Output choices:

? ? -o FILENAME? ? ? ? Specify how the executable should be named. For

? ? ? ? ? ? ? ? ? ? ? ? extension modules there is no choice, also not for

? ? ? ? ? ? ? ? ? ? ? ? standalone mode and using it will be an error. This

? ? ? ? ? ? ? ? ? ? ? ? may include path information that needs to exist

? ? ? ? ? ? ? ? ? ? ? ? though. Defaults to <program_name> on this platform.

? ? ? ? ? ? ? ? ? ? ? ? .exe

? ? --output-dir=DIRECTORY

? ? ? ? ? ? ? ? ? ? ? ? Specify where intermediate and final output files

? ? ? ? ? ? ? ? ? ? ? ? should be put. The DIRECTORY will be populated with C

? ? ? ? ? ? ? ? ? ? ? ? files, object files, etc. Defaults to current

? ? ? ? ? ? ? ? ? ? ? ? directory.

? ? --remove-output? ? Removes the build directory after producing the module

? ? ? ? ? ? ? ? ? ? ? ? or exe file. Defaults to off.

? ? --no-pyi-file? ? ? Do not create a ".pyi" file for extension modules

? ? ? ? ? ? ? ? ? ? ? ? created by Nuitka. This is used to detect implicit

? ? ? ? ? ? ? ? ? ? ? ? imports. Defaults to off.

? Debug features:

? ? --debug? ? ? ? ? ? Executing all self checks possible to find errors in

? ? ? ? ? ? ? ? ? ? ? ? Nuitka, do not use for production. Defaults to off.

? ? --unstripped? ? ? ? Keep debug info in the resulting object file for

? ? ? ? ? ? ? ? ? ? ? ? better debugger interaction. Defaults to off.

? ? --profile? ? ? ? ? Enable vmprof based profiling of time spent. Not

? ? ? ? ? ? ? ? ? ? ? ? working currently. Defaults to off.

? ? --graph? ? ? ? ? ? Create graph of optimization process. Defaults to off.

? ? --trace-execution? Traced execution output, output the line of code

? ? ? ? ? ? ? ? ? ? ? ? before executing it. Defaults to off.

? ? --recompile-c-only? This is not incremental compilation, but for Nuitka

? ? ? ? ? ? ? ? ? ? ? ? development only. Takes existing files and simply

? ? ? ? ? ? ? ? ? ? ? ? compile them as C again. Allows compiling edited C

? ? ? ? ? ? ? ? ? ? ? ? files for quick debugging changes to the generated

? ? ? ? ? ? ? ? ? ? ? ? source, e.g. to see if code is passed by, values

? ? ? ? ? ? ? ? ? ? ? ? output, etc, Defaults to off. Depends on compiling

? ? ? ? ? ? ? ? ? ? ? ? Python source to determine which files it should look

? ? ? ? ? ? ? ? ? ? ? ? at.

? ? --generate-c-only? Generate only C source code, and do not compile it to

? ? ? ? ? ? ? ? ? ? ? ? binary or module. This is for debugging and code

? ? ? ? ? ? ? ? ? ? ? ? coverage analysis that doesn't waste CPU. Defaults to

? ? ? ? ? ? ? ? ? ? ? ? off. Do not think you can use this directly.

? ? --experimental=EXPERIMENTAL

? ? ? ? ? ? ? ? ? ? ? ? Use features declared as 'experimental'. May have no

? ? ? ? ? ? ? ? ? ? ? ? effect if no experimental features are present in the

? ? ? ? ? ? ? ? ? ? ? ? code. Uses secret tags (check source) per experimented

? ? ? ? ? ? ? ? ? ? ? ? feature.

? ? --disable-dll-dependency-cache

? ? ? ? ? ? ? ? ? ? ? ? Disable the dependency walker cache. Will result in

? ? ? ? ? ? ? ? ? ? ? ? much longer times to create the distribution folder,

? ? ? ? ? ? ? ? ? ? ? ? but might be used in case the cache is suspect to

? ? ? ? ? ? ? ? ? ? ? ? cause errors.

? ? --force-dll-dependency-cache-update

? ? ? ? ? ? ? ? ? ? ? ? For an update of the dependency walker cache. Will

? ? ? ? ? ? ? ? ? ? ? ? result in much longer times to create the distribution

? ? ? ? ? ? ? ? ? ? ? ? folder, but might be used in case the cache is suspect

? ? ? ? ? ? ? ? ? ? ? ? to cause errors or known to need an update.

? Backend C compiler choice:

? ? --clang? ? ? ? ? ? Enforce the use of clang. On Windows this requires a

? ? ? ? ? ? ? ? ? ? ? ? working Visual Studio version to piggy back. Defaults

? ? ? ? ? ? ? ? ? ? ? ? to off.

? ? --mingw64? ? ? ? ? Enforce the use of MinGW64 on Windows. Defaults to

? ? ? ? ? ? ? ? ? ? ? ? off.

? ? --msvc=MSVC? ? ? ? Enforce the use of specific MSVC version on Windows.

? ? ? ? ? ? ? ? ? ? ? ? Allowed values are e.g. 14.0, specify an illegal value

? ? ? ? ? ? ? ? ? ? ? ? for a list of installed compilers.? Defaults to the

? ? ? ? ? ? ? ? ? ? ? ? most recent version.

? ? -j N, --jobs=N? ? ? Specify the allowed number of parallel C compiler

? ? ? ? ? ? ? ? ? ? ? ? jobs. Defaults to the system CPU count.

? ? --lto? ? ? ? ? ? ? Use link time optimizations if available and usable

? ? ? ? ? ? ? ? ? ? ? ? (gcc 4.6 and higher). Defaults to off.

? Tracing features:

? ? --show-scons? ? ? ? Operate Scons in non-quiet mode, showing the executed

? ? ? ? ? ? ? ? ? ? ? ? commands. Defaults to off.

? ? --show-progress? ? Provide progress information and statistics. Defaults

? ? ? ? ? ? ? ? ? ? ? ? to off.

? ? --show-memory? ? ? Provide memory information and statistics. Defaults to

? ? ? ? ? ? ? ? ? ? ? ? off.

? ? --show-modules? ? ? Provide a final summary on included modules. Defaults

? ? ? ? ? ? ? ? ? ? ? ? to off.

? ? --verbose? ? ? ? ? Output details of actions taken, esp. in

? ? ? ? ? ? ? ? ? ? ? ? optimizations. Can become a lot. Defaults to off.

? Windows specific controls:

? ? --windows-dependency-tool=DEPENDENCY_TOOL

? ? ? ? ? ? ? ? ? ? ? ? When compiling for Windows, use this dependency tool.

? ? ? ? ? ? ? ? ? ? ? ? Defaults to depends.exe, other allowed value is

? ? ? ? ? ? ? ? ? ? ? ? 'pefile'.

? ? --windows-disable-console

? ? ? ? ? ? ? ? ? ? ? ? When compiling for Windows, disable the console

? ? ? ? ? ? ? ? ? ? ? ? window. Defaults to off.

? ? --windows-icon=ICON_PATH

? ? ? ? ? ? ? ? ? ? ? ? Add executable icon (Windows only).

? Plugin control:

? ? --plugin-enable=PLUGINS_ENABLED, --enable-plugin=PLUGINS_ENABLED

? ? ? ? ? ? ? ? ? ? ? ? Enabled plugins. Must be plug-in names. Use --plugin-

? ? ? ? ? ? ? ? ? ? ? ? list to query the full list and exit. Default empty.

? ? --plugin-disable=PLUGINS_DISABLED, --disable-plugin=PLUGINS_DISABLED

? ? ? ? ? ? ? ? ? ? ? ? Disabled plugins. Must be plug-in names. Use --plugin-

? ? ? ? ? ? ? ? ? ? ? ? list to query the full list and exit. Default empty.

? ? --plugin-no-detection

? ? ? ? ? ? ? ? ? ? ? ? Plugins can detect if they might be used, and the you

? ? ? ? ? ? ? ? ? ? ? ? can disable the warning via --plugin-disable=plugin-

? ? ? ? ? ? ? ? ? ? ? ? that-warned, or you can use this option to disable the

? ? ? ? ? ? ? ? ? ? ? ? mechanism entirely, which also speeds up compilation

? ? ? ? ? ? ? ? ? ? ? ? slightly of course as this detection code is run in

? ? ? ? ? ? ? ? ? ? ? ? vain once you are certain of which plug-ins to use.

? ? ? ? ? ? ? ? ? ? ? ? Defaults to off.

? ? --plugin-list? ? ? Show list of all available plugins and exit. Defaults

? ? ? ? ? ? ? ? ? ? ? ? to off.

? ? --user-plugin=USER_PLUGINS

? ? ? ? ? ? ? ? ? ? ? ? The file name of user plugin. Can be given multiple

? ? ? ? ? ? ? ? ? ? ? ? times. Default empty.


python庫版本信息查詢

Archived: Python Extension Packages for Windows - Christoph Gohlke (uci.edu)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市论寨,隨后出現(xiàn)的幾起案子星立,更是在濱河造成了極大的恐慌,老刑警劉巖葬凳,帶你破解...
    沈念sama閱讀 221,820評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件绰垂,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡火焰,警方通過查閱死者的電腦和手機(jī)劲装,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,648評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人占业,你說我怎么就攤上這事绒怨。” “怎么了谦疾?”我有些...
    開封第一講書人閱讀 168,324評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵南蹂,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我念恍,道長(zhǎng)六剥,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,714評(píng)論 1 297
  • 正文 為了忘掉前任峰伙,我火速辦了婚禮疗疟,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘瞳氓。我一直安慰自己策彤,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,724評(píng)論 6 397
  • 文/花漫 我一把揭開白布顿膨。 她就那樣靜靜地躺著锅锨,像睡著了一般。 火紅的嫁衣襯著肌膚如雪恋沃。 梳的紋絲不亂的頭發(fā)上必搞,一...
    開封第一講書人閱讀 52,328評(píng)論 1 310
  • 那天,我揣著相機(jī)與錄音囊咏,去河邊找鬼恕洲。 笑死,一個(gè)胖子當(dāng)著我的面吹牛梅割,可吹牛的內(nèi)容都是我干的霜第。 我是一名探鬼主播,決...
    沈念sama閱讀 40,897評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼户辞,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼泌类!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起底燎,我...
    開封第一講書人閱讀 39,804評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤刃榨,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后双仍,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體枢希,經(jīng)...
    沈念sama閱讀 46,345評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,431評(píng)論 3 340
  • 正文 我和宋清朗相戀三年朱沃,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了苞轿。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片茅诱。...
    茶點(diǎn)故事閱讀 40,561評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖搬卒,靈堂內(nèi)的尸體忽然破棺而出瑟俭,到底是詐尸還是另有隱情,我是刑警寧澤秀睛,帶...
    沈念sama閱讀 36,238評(píng)論 5 350
  • 正文 年R本政府宣布尔当,位于F島的核電站,受9級(jí)特大地震影響蹂安,放射性物質(zhì)發(fā)生泄漏椭迎。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,928評(píng)論 3 334
  • 文/蒙蒙 一田盈、第九天 我趴在偏房一處隱蔽的房頂上張望畜号。 院中可真熱鬧,春花似錦允瞧、人聲如沸简软。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,417評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽痹升。三九已至,卻和暖如春畦韭,著一層夾襖步出監(jiān)牢的瞬間疼蛾,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,528評(píng)論 1 272
  • 我被黑心中介騙來泰國(guó)打工艺配, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留察郁,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,983評(píng)論 3 376
  • 正文 我出身青樓转唉,卻偏偏與公主長(zhǎng)得像皮钠,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子赠法,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,573評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容