从一个简单的 YAML 配置文件创建一个版本文件
项目描述
pyinstaller-versionfile
从 PyInstaller 可以使用的简单 YAML 文件创建一个 windows 版本文件。
背景
Pyinstaller 提供了一种 通过所谓的版本文件捕获 Windows 版本数据的方法。制作这样一个版本文件的过程,特别是保持版本号更新,有点麻烦。这个包旨在使创建这样的版本文件更容易。
用法
pyinstaller-versionfile 提供命令行界面和功能 API。
命令行界面
pyinstaller-versionfile 提供了一个命令行界面,用于将简单的 YAML 文件转换为适合通过--version-file=选项传递给 PyInstaller 的版本文件。
完整的 YAML 配置如下所示:
Version: 1.2.3.4
CompanyName: My Imaginary Company
FileDescription: Simple App
InternalName: Simple App
LegalCopyright: © My Imaginary Company. All rights reserved.
OriginalFilename: SimpleApp.exe
ProductName: Simple App
编码必须是 UTF-8。
要从中创建版本文件,只需运行:
create-version-file metadata.yml --outfile file_version_info.txt
其中 metadata.yml 是上面的 YAML 配置文件。
提取版本信息
作为直接在 YAML 文件中指定版本的替代方法,有两种替代方法可能更合适,具体取决于用例:
链接到外部文件
除了将版本字符串直接写入 YAML 文件之外,您还可以指定另一个文件的(相对)路径。请注意,此文件必须仅包含版本字符串,不得包含其他内容。
Version: VERSION.txt
CompanyName: My Imaginary Company
FileDescription: Simple App
InternalName: Simple App
LegalCopyright: © My Imaginary Company. All rights reserved.
OriginalFilename: SimpleApp.exe
ProductName: Simple App
从命令行设置版本
也可以使用以下--version选项直接在命令行上设置版本:
create-version-file metadata.yml --outfile file_version_info.txt --version 0.8.1.5
如果您想使用 CI 内部版本号作为版本,这会很有用。
函数式 API
您还可以通过直接调用功能 API 来使用您自己的 python 代码中的 pyinstaller-versionfile。
import pyinstaller_versionfile
pyinstaller_versionfile.create_versionfile_from_input_file(
output_file="versionfile.txt",
input_file="metadata.yml",
version="1.2.3.4" # optional, can be set to overwrite version information (equivalent to --version when using the CLI)
)
不必使用文件作为输入,也可以直接指定所需的值。所有这些都是可选的,如果未指定,将用占位符值填充。
import pyinstaller_versionfile
pyinstaller_versionfile.create_versionfile(
output_file="versionfile.txt",
version="1.2.3.4",
company_name="My Imaginary Company",
file_description="Simple App",
internal_name="Simple App",
legal_copyright="© My Imaginary Company. All rights reserved.",
original_filename="SimpleApp.exe",
product_name="Simple App"
)
贡献
如果你认为你发现了一个错误,或者有改进的建议,不要犹豫,创建一个新问题或提交一个拉取请求。我会尽快调查。
变更日志
(即将面世...)
新的
- 使用 gitchangelog 自动生成变更日志。[杜登33]
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
pyinstaller_versionfile-2.0.0.tar.gz
(15.2 kB
查看哈希)
内置分布
关
pyinstaller_versionfile -2.0.0.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 95f9a6282001fe15e3ee62f7fd55cf45202d99779b4a00c37c16466a0c6e9705 |
|
| MD5 | dab6da0f35739e9faa62ffe86f3573c5 |
|
| 布莱克2-256 | bf86dc44481bfa09c156b2c08c0c1caaa33f986689440a4a0b960bd87dcfe1d2 |
关
pyinstaller_versionfile -2.0.0-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 2f150c82e9938c9533c90c7ed3aa6abff69998475ce572c5216f80c6335db3e0 |
|
| MD5 | c5f9f3c7560447def01131851543f4e2 |
|
| 布莱克2-256 | 8e8a6b67fa69b14a4d24e60fa53b92cae86bd18910e7b74ecc1a4ddb527dcb98 |