Skip to content

Configuring project metadata


プロジェクトのメタデータは、プロジェクトのツリーのルートにあるpyproject.tomlファイルに保存されます。

完全にthe standardに基づいています。

Name (required)

プロジェクトの名前。

[project]
name = "your-app"

Version (required)

See the dedicated versioning section.

[project]
...
dynamic = ["version"]

[tool.hatch.version]
path = "..."
[project]
...
version = "0.0.1"

Description

プロジェクトの簡単な概要

[project]
...
description = '...'

Readme

プロジェクトの完全な説明。

The file extension must be .md, .rst, or .txt.

[project]
...
readme = "README.md"

The content-type field must be set to text/markdown, text/x-rst, or text/plain.

A charset field may also be set to instruct which encoding to use for reading the file, defaulting to utf-8.

[project]
...
readme = {"file" = "README.md", "content-type" = "text/markdown"}

The content-type field must be set to text/markdown or text/x-rst.

[project]
...
readme = {"text" = "...", "content-type" = "text/markdown"}

Note

これがファイルとして定義されている場合、一貫性のあるビルドのために常にsource distributionsに含まれます。

Python support

プロジェクトのPythonバージョン要件。

[project]
...
requires-python = ">=3.8"

License

詳細はPEP 639を参照のこと。

[project]
...
license = "Apache-2.0 OR MIT"
[project]
...
license-files = { paths = ["LICENSE.txt"] }
[project]
...
license-files = { globs = ["LICENSES/*"] }

Ownership

プロジェクトのauthors またはmaintainersと見なされる人または組織。

正確な意味は解釈の余地があります。元の作成者または主な作成者、現在のメンテナ、またはパッケージの所有者をリストすることができます。値が同じ場合は、authorsフィールドのみを使用することをお勧めします。

[project]
...
authors = [
  { name = "...", email = "..." },
]
maintainers = [
  { name = "...", email = "..." },
]

Keywords

プロジェクトの発見を支援するために使用されるキーワード。

[project]
...
keywords = [
  "...",
]

Classifiers

プロジェクトに適用されるtrove classifiers

[project]
...
classifiers = [
  "...",
]

URLs

キーがURLラベルで、値がURL自体であるURLのテーブル。

[project.urls]
Documentation = "..."
"Source code" = "..."

Dependencies

詳細については、dependency specificationページを参照してください。

エントリは、デフォルトでcontext formattingdisallow direct referencesをサポートします。

Required

[project]
...
dependencies = [
  "...",
]

Optional

[project.optional-dependencies]
option1 = [
  "...",
]
option2 = [
  "...",
]

Entry points

Entry pointsは、プロジェクトが提供するコンポーネントを他のコードによって検出および使用されるようにアドバタイズするためのメカニズムです。

CLI

CLIスクリプトを定義するプロジェクトをインストールした後、各キーは、関連するオブジェクトを呼び出すコマンドとしてPATHで使用できるようになります。

[project.scripts]
cli-name = "pkg.subpkg:func"

上記の例では、cli-nameを実行すると、基本的に次のPythonスクリプトが実行されます。:

import sys

from pkg.subpkg import func

sys.exit(func())

GUI

GUIスクリプトはCLIスクリプトとまったく同じですが、Windowsではコンソールなしで起動できるように特別に処理されます。

[project.gui-scripts]
gui-name = "pkg.subpkg:func"

Plugins

[project.entry-points.plugin-namespace]
plugin-name1 = "pkg.subpkg1"
plugin-name2 = "pkg.subpkg2:func"

Dynamic

versionのように、メタデータフィールドが動的に設定されている場合は、ここにリストする必要があります。

[project]
...
dynamic = [
  "...",
]

Metadata options

Allowing direct references

デフォルトでは、dependenciesdirect referencesを定義することはできません。このチェックを無効にするには、allow-direct-referencestrueに設定します。:

[tool.hatch.metadata]
allow-direct-references = true
[metadata]
allow-direct-references = true

Allowing ambiguous features

デフォルトでは、optional dependenciesの名前はあいまいさを防ぐために正規化されます。この正規化を無効にするには、allow-ambiguous-featurestrueに設定します::

[tool.hatch.metadata]
allow-ambiguous-features = true
[metadata]
allow-ambiguous-features = true

Deprecated

このオプションは、まだPEP 685をサポートしていないツールとの相互運用性を向上させるために一時的に存在しており、2024年1月1日以降の最初のマイナーリリースで削除される予定です。