Pythonスクリプトのパッケージ化
from 20240901
Python Packaging User Guide
Creating and packaging command-line tools
pipxでインストールできるスタンドアロンのCLIアプリ/パッケージの作成、インストール手順までを解説しているページ。
Creating and packaging command-line tools
Writing your pyproject.toml
pyproject.tomlの内容について解説しているページ
As of August 2024, Poetry is a notable build backend that does not use the [project] table, it uses the [tool.poetry] table instead. Also, the setuptools build backend supports both the [project] table, and the older format in setup.cfg or setup.py.
2024年現在Poetryが[Project]テーブルを利用しない有名なBuilld backend
代わりに[tool.poetry]テーブルを用いる
SetuptoolsのBuilld backend
[project]テーブルと古いsetup.cfgかsetup.pyの両方をサポートする
パッケージ管理やパッケージの作成にPoetryを利用している場合
[project]テーブルは[tool.poetry]に全て置き換えてよい
以下はgreetコマンドを利用可能にする例
poetry run greetでも実行できる
code:pyproject.toml
tools.poetry.script
greet = "greetings.cli:app"
https://python-poetry.org/docs/pyproject#scripts
コマンド化については以下のページを見る
Creating executable scripts
flat layoutとsrc layoutの比較