Skip to content

Configuring project metadataプロジェクトメタデータの設定


Project metadata is stored in a pyproject.toml file located at the root of a project's tree and is based entirely on the standard.プロジェクトメタデータは、プロジェクトツリーのルートにあるpyproject.tomlファイルに保存され、完全に標準に基づいています。

Name (required)名前(必須

The name of the project.プロジェクトの名前。

[project]
name = "your-app"

Version (required)バージョン(必須

See the dedicated versioning section.専用のバージョニングセクションを参照してください。

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

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

Description説明

A brief summary of the project.プロジェクトの簡単な概要。

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

ReadmeReadme

The full description of the project.プロジェクトの完全な説明。

The file extension must be .md, .rst, or .txt.ファイル拡張子は .md, .rst, または .txt でなければなりません。

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

The content-type field must be set to text/markdown, text/x-rst, or text/plain.content-type フィールドは text/markdown, text/x-rst, または text/plain に設定する必要があります。

A charset field may also be set to instruct which encoding to use for reading the file, defaulting to utf-8.charset フィールドを設定してファイルを読み込む際のエンコーディングを指示することもでき、デフォルトは 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.content-type フィールドは text/markdown または text/x-rst に設定する必要があります。

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

Note注意

If this is defined as a file, then it will always be included in source distributions for consistent builds.これがファイルとして定義されている場合、常に ソース配布 に含まれ、一貫したビルドが行われます。

Python supportPython サポート

The Python version requirements of the project.プロジェクトの Python バージョン要件。

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

Licenseライセンス

For more information, see PEP 639.詳細については、PEP 639を参照してください。

[project]
...
license = "Apache-2.0 OR MIT"
[project]
...
license-files = ["LICENSES/*"]

Ownership所有権

The people or organizations considered to be the authors or maintainers of the project. The exact meaning is open to interpretation; it may list the original or primary authors, current maintainers, or owners of the package. If the values are the same, prefer only the use of the authors field.プロジェクトのauthorsまたはmaintainersと見なされる人々または組織。正確な意味は解釈に依存し、元のまたは主要な著者、現在のメンテナー、またはパッケージの所有者をリストする場合があります。値が同じ場合は、authorsフィールドの使用を優先してください。

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

Keywordsキーワード

The keywords used to assist in the discovery of the project.プロジェクトの発見を助けるために使用されるキーワード。

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

Classifiers分類子

The trove classifiers that apply to the project.プロジェクトに適用されるtrove classifiers

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

URLsURL

A table of URLs where the key is the URL label and the value is the URL itself.キーがURLラベルで、値がURLそのものであるURLのテーブル。

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

Dependencies依存関係

See the dependency specification page for more information.詳細については、依存関係仕様ページを参照してください。

Entries support context formatting and disallow direct references by default.エントリはデフォルトでコンテキストフォーマット直接参照を禁止をサポートします。

Required必須

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

Optionalオプション

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

Entry pointsエントリポイント

Entry points are a mechanism for the project to advertise components it provides to be discovered and used by other code.エントリポイントは、プロジェクトが提供するコンポーネントを他のコードが発見して使用できるように宣伝するためのメカニズムです。

CLICLI

After installing projects that define CLI scripts, each key will be available along your PATH as a command that will call its associated object.CLIスクリプトを定義するプロジェクトをインストールした後、各キーはその関連オブジェクトを呼び出すコマンドとしてPATHに沿って利用可能になります。

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

Using the above example, running cli-name would essentially execute the following Python script:上記の例を使用すると、cli-nameを実行すると、実際には次のPythonスクリプトが実行されます:

import sys

from pkg.subpkg import func

sys.exit(func())

GUIGUI

GUI scripts are exactly the same as CLI scripts except on Windows, where they are handled specially so that they can be started without a console.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動的

If any metadata fields are set dynamically, like the version may be, then they must be listed here.もし、versionのように、メタデータフィールドが動的に設定されている場合は、ここにリストする必要があります。

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

Metadata optionsメタデータオプション

Allowing direct references直接参照を許可する

By default, dependencies are not allowed to define direct references. To disable this check, set allow-direct-references to true:デフォルトでは、依存関係直接参照を定義することは許可されていません。このチェックを無効にするには、allow-direct-referencestrueに設定します:

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

Allowing ambiguous featuresあいまいな機能を許可する

By default, names of optional dependencies are normalized to prevent ambiguity. To disable this normalization, set allow-ambiguous-features to true:デフォルトでは、オプショナル依存関係の名前はあいまいさを防ぐために正規化されます。この正規化を無効にするには、allow-ambiguous-featurestrueに設定します:

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

Deprecated非推奨

This option temporarily exists to provide better interoperability with tools that do not yet support PEP 685 and will be removed in the first minor release after Jan 1, 2024.このオプションは、まだPEP 685をサポートしていないツールとの互換性を向上させるために一時的に存在しており、2024年1月1日以降の最初のマイナーリリースで削除される予定です。