Skip to content

Hatch v1.6.0Hatch v1.6.0

Hatch v1.6.0 brings improvements to build environments, better handling of dynamic metadata, and support for tools like Visual Studio Code.Hatch v1.6.0 は、ビルド環境の改善、動的メタデータのより良い処理、Visual Studio Codeなどのツールのサポートを提供します。

Build environmentsビルド環境

Originally, the environment interface method for providing builder sub-environments was intended to be used in conjunction with some cleanup logic in order to provide a fresh setup every time. However, this is unnecessary in practice because build dependencies rarely change.元々、ビルダーサブ環境を提供するための環境インターフェースメソッドは、毎回新しいセットアップを提供するためにクリーンアップロジックと併用することを意図していました。しかし、実際にはビルド依存関係はほとんど変わらないため、これは不要です。

Without caching, repeat build environment use is slow which affects the following scenarios:キャッシュなしでは、繰り返しビルド環境を使用するのが遅くなり、以下のシナリオに影響を与えます:

Now a new environment interface method build_environment_exists is used by Hatch to determine whether or not it has already been created, for implementations that have a caching mechanism.現在、新しい環境インターフェースメソッドbuild_environment_existsがHatchによって使用され、キャッシュメカニズムを持つ実装に対して、すでに作成されているかどうかを判断します。

The virtual environment type now uses this method to cache build environments.virtual環境タイプは、ビルド環境をキャッシュするためにこのメソッドを使用します。

Project metadataプロジェクトメタデータ

Dynamically defined metadata is now supported everywhere, thanks to the new caching of virtual build environments.新しいvirtualビルド環境のキャッシュのおかげで、動的に定義されたメタデータがどこでもサポートされるようになりました。

A project metadata command is introduced that displays the fully resolved metadata. The output format is JSON unless a field is specified as an argument.project metadataコマンドが導入され、完全に解決されたメタデータを表示します。出力形式は、フィールドが引数として指定されない限りJSONです。

For example, if you checkout a project that is built by Hatch, like FastAPI, and run:例えば、FastAPIのようにHatchによって構築されたプロジェクトをチェックアウトし、実行すると:

hatch project metadata readme

only the readme text will be displayed. If the content is in Markdown, then Rich will render it directly in your terminal:表示されるのはreadmeテキストのみです。コンテンツがMarkdownの場合、Richがそれを直接ターミナルにレンダリングします:

FastAPI readme

Virtual environment location仮想環境の場所

The virtual environment type now uses a flat layout for storage in the configured virtual environment directory if the directory resides somewhere within the project root or if it is set to a .virtualenvs directory within the user's home directory.virtual環境タイプは、プロジェクトルート内のどこかにディレクトリが存在する場合、またはユーザーのホームディレクトリ内の.virtualenvsディレクトリに設定されている場合、構成されたvirtual 環境ディレクトリにストレージのフラットレイアウトを使用します。

For example, if you define the following Hatch configuration:例えば、次のHatch構成を定義した場合:

[dirs.env]
virtual = ".hatch"

and the following matrix:次のマトリックス:

[[tool.hatch.envs.test.matrix]]
python = ["3.7", "3.8", "3.9", "3.10", "3.11"]
[[envs.test.matrix]]
python = ["3.7", "3.8", "3.9", "3.10", "3.11"]

then locating environments with the following command:次のコマンドで環境を見つけると:

hatch env find test

will show that the general directory structure is:一般的なディレクトリ構造が表示されます:

.hatch
├── test.py3.7
├── test.py3.8
├── test.py3.9
├── test.py3.10
└── test.py3.11

This flat structure is required for detection of virtual environments by tools like Visual Studio Code and PyCharm.このフラットな構造は、Visual Studio CodeやPyCharmのようなツールによる仮想環境の検出に必要です。

Additionally, the virtual environment type now supports a path option to specify an explicit path that all inherited environments will share, such as the common .venv.さらに、virtual環境タイプは、すべての継承された環境が共有する明示的なパスを指定するpathオプションをサポートするようになりました。例えば、共通の.venvなどです。

Migration script improvementsマイグレーションスクリプトの改善

The script used to migrate existing projects from setuptools has been improved to handle more edge cases that were encountered in the wild and now no longer modifies the formatting of existing pyproject.toml configuration.スクリプトは、setuptoolsから既存プロジェクトを移行するために改善され、実際に遭遇したより多くのエッジケースに対応できるようになり、既存のpyproject.toml設定のフォーマットを変更しなくなりました。

HatchlingHatchling

Hatch now depends on Hatchling v1.11.0, which was also just released.Hatchは、最近リリースされたHatchling v1.11.0に依存するようになりました。

Environment version source環境バージョンソース

A new env version source is available that allows for the project version to be defined by an environment variable.プロジェクトバージョンを環境変数で定義できる新しいenvバージョンソースが利用可能です。

Relaxed version bumping緩和されたバージョンバンプ

The standard version scheme now supports a validate-bump option that when set to false will forego the check when updating the version that the desired version is higher than the current version.standardバージョンスキームは、falseに設定すると、バージョンを更新する際に、希望するバージョンが現在のバージョンよりも高いかどうかのチェックを省略するvalidate-bumpオプションをサポートするようになりました。

This use case comes from Project Jupyter:このユースケースはProject Jupyterから来ています:

A common pattern we use in Jupyter is to bump to a .dev0 minor version bump after making a release. If we have a bug fix that needs to go out in the interim, we'd rather not be forced to create a branch every time.Jupyterでよく使われるパターンは、リリース後に.dev0のマイナーバージョンバンプを行うことです。もしその間に出さなければならないバグ修正があれば、毎回ブランチを作成することを強いられたくありません。