有没有一种方法可以使用给定的进程描述编译Python脚本?例如,我有一个名为'main.py'的文件,编译后我得到了'main.exe'。当我运行我的脚本时,在任务管理器中会显示'main',但我想要像'My python script'这样的东西。使用PyInstaller是否可能实现这个目标?
有没有一种方法可以使用给定的进程描述编译Python脚本?例如,我有一个名为'main.py'的文件,编译后我得到了'main.exe'。当我运行我的脚本时,在任务管理器中会显示'main',但我想要像'My python script'这样的东西。使用PyInstaller是否可能实现这个目标?
当然,这是可能的。你需要做的是(请参阅此处的文档):
exe
文件pyi-grab_version C:\path\to\that\file.exe
file_version_info.txt
pyinstaller --version-file=file_version_info.txt main.py
如果你使用 pyinstaller spec file 构建你的 exe,则可以用以下内容替换第4步:
main.spec
文件中添加 version='file_version_info.txt'
:exe = EXE(...
...
version='file_version_info.txt'
)
pyinstaller main.spec
。示例
在您的情况下,您想要编辑的元数据类别是file_version_info.txt
中的FileDescription
。以下是一个file_version_info.txt
文件的示例:
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(1, 2, 3, 0),
prodvers=(1, 2, 3, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x40004,
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,
# Creation date and time stamp.
date=(0, 0)
),
kids=[
StringFileInfo(
[
StringTable(
u'040904b0',
[StringStruct(u'CompanyName', u'MyCompany'),
StringStruct(u'FileDescription', u'MyApp'),
StringStruct(u'FileVersion', u'1.23.0'),
StringStruct(u'InternalName', u'cardprocess'),
StringStruct(u'LegalCopyright', u'No Copyright © 2020'),
StringStruct(u'OriginalFilename', u'myapp.exe'),
StringStruct(u'ProductName', u'myapp'),
StringStruct(u'ProductVersion', u'1.23.0')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)