python - 编辑或更改已编译的 python 脚本(.exe 文件)详细信息

标签 python python-3.x metadata executable

我的问题是:有没有办法轻松设置 .exe 文件的详细信息/元数据?

我创建了一个可用的 python 程序,并使用 pyinstaller 将其编译为 .exe 文件。 当我右键单击已编译的程序并转到“属性”>“详细信息”时,它看起来像这样:

脚本.exe

--Description-------------------
File Description
Type          Application
File Version
Product Name
Product Version
Copyright
Size          37.0 MB
Date Modified  xx/xx/2020
Language

我希望能够更改此元数据。

最好是有一种方法可以做到这一点,这样我所要做的就是添加另一个自动设置此数据的文件。

我发现最接近的东西是 Resouces.rc 文件,该文件在用 C++ 或 C# 制作的项目中使用。

有什么办法可以解决这个问题吗? 你是怎么做到的?

最佳答案

已解决。

我所要做的就是创建这个 version.txt 并填写相关信息。

版本.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=(x, x, x, x), #<- Put File version here
    # prodvers=(3, 0, 10, 2),
    # Contains a bitmask that specifies the valid bits 'flags'
    mask=0x3f, #<- Do not change
    # Contains a bitmask that specifies the Boolean attributes of the file.
    flags=0x0, #<- Do not change
    # The operating system for which this file was designed.
    # 0x4 - NT and there is no need to change it.
    OS=0x4, #<- Do not change
    # The general type of file.
    # 0x1 - the file is an application.
    fileType=0x1, #<- Do not change
    # The function of the file.
    # 0x0 - the function is not defined for this fileType
    subtype=0x0, #<- Do not change
    # Creation date and time stamp. Sets it automatically. Do not change.
    date=(0, 0) #<- Do not change
    ),
  kids=[ 
    StringFileInfo( 
      [ 
      StringTable(
        u'040904b0',
        [StringStruct(u'CompanyName', u'Your name here'),
        StringStruct(u'ProductName', u'name here'),
        StringStruct(u'ProductVersion', u'x.x.x.x'), #<- should be same as filevers
        StringStruct(u'OriginalFilename', u'productname.exe'),
        StringStruct(u'FileDescription', u'Short description goes here'),
        StringStruct(u'LegalCopyright', u'copyright stuff here'),
        StringStruct(u'LegalTrademarks', u'legal stuff here'),])
      ]),
    VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
  ]
)

创建后,我可以使用 --version-file version.txt 将其添加到我的 Pyinstaller 创建命令中

关于python - 编辑或更改已编译的 python 脚本(.exe 文件)详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61425976/

相关文章:

python-3.x - 如何从远程python服务连接到CDH集群

ruby-on-rails - 在 Rails 3.2.6 中使用 Paperclip-FFMPEG 从视频中获取元数据

c# - 在生成的部分类上使用 XmlIgnore

python - 使用 `format` 获取字符串的最后一个字符

python - 为什么 *args 不适用于字符串格式

python - "{%"在 HTML 中有什么作用?

python - 如何使用 pip 更新 Python 标准库包?

python-3.x - Keras 二元分类将输出压缩为 0/1

php - 在 WooCommerce 快速订单预览中显示自定义字段

python - 从 LDAP 获取组到 django