コマンドラインリファレンスガイド#

重要

これらの表は何であるか: これらの表は、Hatch のインストールから PyPI や conda-forge でのパッケージの公開まで、パッケージ作成プロセスのすべてのステップを完了するために必要なコマンドライン入力 (e.g., pipx install hatch, hatch build) をまとめたものです。

これらの表は何でないか: これらの表は、パッケージの作成プロセスを通して完了しなければならない手動/非自動ステップ (PyPIアカウントの作成、PyPI APIトークンの作成など) をカバーしていません。

オペレーティングシステム: 本ガイドの現在のバージョンは、Windows OSのみでテストされています。多くのコマンドはWindows固有のものでス。OS固有のコマンドは、コマンドの説明の後に [COMMAND_DESCRIPTION] (Windows) のように括弧をつけて表示されます。 macOSとLinuxに対応するコマンドは今後追加されます。

環境設定#

Description

Syntax

Set PowerShell execution policy (Windows)

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Install Scoop (Windows)

Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

Add "main" bucket as download source (Windows)

scoop bucket add main

Add "versions" bucket as download source (Windows)

scoop bucket add versions

Install pipx (Windows)

scoop install pipx or scoop install main/pipx

Update PATH variable with pipx directory

pipx ensurepath

Install hatch

pipx install hatch or pip install hatch

List hatch commands

hatch -h

Open location of hatch config file

hatch config explore

Print contents of hatch config file

hatch config show

Install grayskull

pipx install grayskull or pip install grayskull

パッケージ開発#

Description

Syntax

Create package structure and baseline contents

hatch new [PACKAGE_NAME]

Install package locally in editable mode

python -m pip install -e .

Install development dependencies

python -m pip install ".[DEPENDENCY_GROUP]"

List packages installed in current environment

pip list

Install package from GitHub

pip install git+https://github.com/user/repo.git@branch_or_tag

Create development environment

hatch env create

Activate development environment

hatch shell

Exit development environment

exit

パッケージパブリッシング#

Description

Syntax

Build package sdist and wheel distributions

hatch build

Publish package to Test PyPI

hatch publish -r test

Install package from Test PyPI

pip install -i https://test.pypi.org/simple/ [PACKAGE_NAME]

Publish package to PyPI

hatch publish

Install package from PyPI

pip install -i https://pypi.org/simple/ [PACKAGE_NAME]

Create conda-forge recipe

grayskull pypi [PACKAGE_NAME]

Check that package installs properly

pip check

Install package from conda-forge

conda install -c conda-forge [PACKAGE_NAME]

バージョンと環境#

Description

Syntax

View environments

hatch env show

Print path to active hatch environment

hatch env find

Bump package version - major

hatch version major

Bump package version - minor

hatch version minor

Bump package version - patch

hatch version patch

Run test scripts on multiple Python versions

hatch run all:[SCRIPT_NAME]