Code version source¶コードバージョンソース¶
Updates¶更新¶
Setting the version is not supported.バージョンの設定はサポートされていません。
Configuration¶設定¶
The version source plugin name is code.バージョンソースプラグイン名は code です。
[tool.hatch.version]
source = "code"
[version]
source = "code"
Options¶オプション¶
| Optionオプション | Description説明 |
|---|---|
path (required)path(必須) | A relative path to a Python file or extension module that will be loaded読み込まれるPythonファイルまたは拡張モジュールへの相対パス |
expressionexpression | A Python expression that when evaluated in the context of the loaded file returns the version. The default expression is simply __version__.読み込まれたファイルのコンテキストで評価されるとバージョンを返すPython式。デフォルトの式は単に __version__ です。 |
search-pathssearch-paths | A list of relative paths to directories that will be prepended to Python's search pathPythonの検索パスに追加されるディレクトリへの相対パスのリスト |
Missing imports¶不足しているインポート¶
If the chosen path imports another module in your project, then you'll need to use absolute imports coupled with the search-paths option. For example, say you need to load the following file:選択したパスがプロジェクト内の別のモジュールをインポートする場合、search-pathsオプションと組み合わせて絶対インポートを使用する必要があります。たとえば、次のファイルを読み込む必要があるとします:
from ._version import get_version
__version__ = get_version()
You should change it to:これを次のように変更する必要があります:
from pkg._version import get_version
__version__ = get_version()
and the configuration would become:そして、設定は次のようになります:
[tool.hatch.version]
source = "code"
path = "src/pkg/__init__.py"
search-paths = ["src"]
[version]
source = "code"
path = "src/pkg/__init__.py"
search-paths = ["src"]