Skip to content

Version build hookバージョンビルドフック


This writes the project's version to a file.これにより、プロジェクトのバージョンがファイルに書き込まれます。

Configuration設定

The build hook plugin name is version.ビルドフックプラグイン名はversionです。

[tool.hatch.build.hooks.version]
[tool.hatch.build.targets.<TARGET_NAME>.hooks.version]
[build.hooks.version]
[build.targets.<TARGET_NAME>.hooks.version]

Optionsオプション

Optionオプション Description説明
path (required)path(必須) A relative path to the desired file希望するファイルへの相対パス
templatetemplate A string representing the entire contents of path that will be formatted with a version variablepathの全内容を表す文字列で、version変数でフォーマットされます。
patternpattern Rather than updating the entire file, a regular expression may be used that has a named group called version that represents the version. If set to true, a pattern will be used that looks for a variable named __version__ or VERSION that is set to a string containing the version, optionally prefixed with the lowercase letter v.ファイル全体を更新するのではなく、バージョンを表すversionという名前付きグループを持つ正規表現を使用できます。trueに設定すると、__version__またはVERSIONという名前の変数を探すパターンが使用され、これはバージョンを含む文字列に設定され、オプションで小文字のvで接頭辞が付けられます。