如果我的Python 2脚本是使用Python 4.3打包的,使用定制的.spec
文件,并使用命令
pyinstaller foo.spec
我们如何使用PyArmor 6.7.2来使用相同的.spec
文件打包相同的Python脚本?
运行以下命令
pyarmor pack --name Foo -e '--onefile foo.spec' start.py
导致错误
makespec.py:错误:无法识别的参数:./start.py
我们该怎么解决这个问题?
PyArmor输出:
为什么它仍然试图生成另一个.spec文件?
...
INFO Found runtime module pytransform.py
INFO Copy dist/obf/pytransform.py to temp path
INFO Run PyInstaller to generate .spec file...
INFO
/opt/anaconda3/envs/foo/bin/python -m PyInstaller.utils.cliutils.makespec --onefile foo.spec --name Foo -p dist/obf/temp --hidden-import pytransform --additional-hooks-dir dist/obf/temp ./start.py
INFO ==================== Run command ====================
usage: makespec.py [-h] [-D] [-F] [--specpath DIR] [-n NAME] [--add-data <SRC;DEST or SRC:DEST>] [--add-binary <SRC;DEST or SRC:DEST>] [-p DIR] [--hidden-import MODULENAME] [--collect-submodules MODULENAME] [--collect-data MODULENAME]
[--collect-binaries MODULENAME] [--collect-all MODULENAME] [--copy-metadata PACKAGENAME] [--additional-hooks-dir HOOKSPATH] [--runtime-hook RUNTIME_HOOKS] [--exclude-module EXCLUDES] [--key KEY]
[-d {all,imports,bootloader,noarchive}] [-s] [--noupx] [--upx-exclude FILE] [-c] [-w] [-i <FILE.ico or FILE.exe,ID or FILE.icns or "NONE">] [--version-file FILE] [-m <FILE or XML>] [-r RESOURCE] [--uac-admin]
[--uac-uiaccess] [--win-private-assemblies] [--win-no-prefer-redirects] [--osx-bundle-identifier BUNDLE_IDENTIFIER] [--runtime-tmpdir PATH] [--bootloader-ignore-signals] [--log-level LEVEL]
scriptname [scriptname ...]
makespec.py: error: unrecognized arguments: ./start.py
INFO ==================== End command ====================
ERROR Run command failed
foo.spec:
...
a = Analysis(['start.py'],
pathex=['/home/x/test'],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='foo',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='start')
2条答案
按热度按时间z4iuyo4d1#
如果你的.spec已经被配置为--onefile,你不需要在命令中再次指定它。只要做:
-s标签用于指定.spec文件,如下所示:
https://pyarmor.readthedocs.io/en/latest/man.html
eivgtgni2#
PyArmor 8.0+
参考:https://pyarmor.readthedocs.io/en/stable/tutorial/obfuscation.html#packing-to-one-folder