これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。
HTML ファイル生成日時: 2025/06/19 08:39:27.157 (台灣標準時)
Python のパッケージを作成するとき、 pyproject.toml というファイルを用 意せねばならぬでござる。 hatch というコマンドを使うと、 pyproject.toml の雛形を自動生成してくれるでござる。
まず、 hatch コマンドを使って、 pyproject.toml の雛形の内容を表示させ てみるでござる。
% hatch config show mode = "local" project = "" shell = "" [dirs] project = [] python = "isolated" data = "/home/daisuke/.local/share/hatch" cache = "/home/daisuke/.cache/hatch" [dirs.env] [projects] [template] name = "daisuke" email = "abc@def.ghi" [template.licenses] headers = true default = [ "MIT", ] [template.plugins.default] tests = true ci = false src-layout = true [terminal.styles] info = "bold" success = "bold cyan" error = "bold red" warning = "bold yellow" waiting = "bold magenta" debug = "bold" spinner = "simpleDotsScrolling"
自動生成された雛形のライセンスの部分は、 MIT ライセンスが指定されてい るでござる。
以下のコマンドを実行すると、雛形ファイルを生成する際に使われるファイル の場所がわかるようでござる。
% hatch config find /home/daisuke/.config/hatch/config.toml
/home/daisuke/.config/hatch/config.toml ファイルの内容を見てみるでござ る。
% cat /home/daisuke/.config/hatch/config.toml mode = "local" project = "" shell = "" [dirs] project = [] python = "isolated" data = "/home/daisuke/.local/share/hatch" cache = "/home/daisuke/.cache/hatch" [dirs.env] [projects] [publish.index] repo = "main" [template] name = "daisuke" email = "abc@def.ghi" [template.licenses] headers = true default = [ "MIT", ] [template.plugins.default] tests = true ci = false src-layout = true [terminal.styles] info = "bold" success = "bold cyan" error = "bold red" warning = "bold yellow" waiting = "bold magenta" debug = "bold" spinner = "simpleDotsScrolling"
このファイルを編集すればよいようでござる。ライセンスについては、 SPDX license expression を使って指定しないといけないそうでござる。では、こ の SPDX license expression では、各ライセンスはどのように表記されるの か、というと、それは以下のページを参照すればよいようでござる。
例えば、 GPLv3 は、 "GPL-3.0-only" や "GPL-3.0-or-later" と書けばよいようでござる。
hatch コマンドを使って変更を加えることもできるようでござる。試してみる でござる。
% hatch config set template.name myname New setting: [template] name = "myname"
変更が反映されたかどうか確認してみるでござる。
% hatch config show mode = "local" project = "" shell = "" [dirs] project = [] python = "isolated" data = "/home/daisuke/.local/share/hatch" cache = "/home/daisuke/.cache/hatch" [dirs.env] [projects] [template] name = "myname" email = "abc@def.ghi" [template.licenses] headers = true default = [ "GPL-3.0-or-later", ] [template.plugins.default] tests = true ci = false src-layout = true [terminal.styles] info = "bold" success = "bold cyan" error = "bold red" warning = "bold yellow" waiting = "bold magenta" debug = "bold" spinner = "simpleDotsScrolling"
ライセンスの部分を変更してみるでござる。
% hatch config set template.licenses.default "BSD-3-Clause" Error parsing config: template -> licenses -> default must be an array
失敗してしまったでござる。 array でなくてはいけない、ということなので、 以下を試してみたでござる。
% hatch config set template.licenses.default ["BSD-3-Clause"] hatch: No match.
これも失敗してしまったでござる。以下を試してみたでござる。
% hatch config set template.licenses.default "['BSD-3-Clause']" New setting: [template.licenses] default = ["BSD-3-Clause"]
今度は成功したようでござる。確認してみるでござる。
% hatch config show mode = "local" project = "" shell = "" [dirs] project = [] python = "isolated" data = "/home/daisuke/.local/share/hatch" cache = "/home/daisuke/.cache/hatch" [dirs.env] [projects] [template] name = "myname" email = "abc@def.ghi" [template.licenses] headers = true default = [ "BSD-3-Clause", ] [template.plugins.default] tests = true ci = false src-layout = true [terminal.styles] info = "bold" success = "bold cyan" error = "bold red" warning = "bold yellow" waiting = "bold magenta" debug = "bold" spinner = "simpleDotsScrolling"
確かに BSD ライセンスに変更されているでござる。