Ccmmutty logo
Commutty IT
0 pv3 min read

Poetry 1.x -> 2.x 移行メモ

https://picsum.photos/seed/62b5184f64ea419f98ff0da20f265a71/1200/630

結論

以下のオプションはPoetry v2.xでは廃止済み&非推奨です。

コマンド

  • --no-dev
#### 書き換え ####
# Poerty 1.x
poetry install --no-dev 

# Poerty 2.x
poetry install --without dev

pyproject.toml

  • dev-dependencies
#### 書き換え ####
# Poerty 1.x
[tool.poetry.dev-dependencies]

# Poerty 2.x
[tool.poetry.group.dev.dependencies]
  • package-mode = falseを追記
    • パッケージ化を無効化するオプションなので、プロジェクトに合わせてbool値を変更してください。
    • Poetryを依存関係管理ツールとして使用している場合はfalseでOK。
#### 追記 ####
# Poerty 1.x
[tool.poetry]

# Poerty 2.x
[tool.poetry]
package-mode = false  # 追記
私が使用していないもので他にも変更があったり削除されているコマンドがいくつかあったため、詳細ついてはこちらを参照。

遭遇した事象

  • Poetryのアップデートを行ったところ、既存ファイルをそのままでDocker等でpoetry installが通らなくなった。
    • Poetry 2.0.0 は 2025年01月05日にリリース

実際に出たエラーログ

  • --no-dev オプションに関するエラー
The option "--no-dev" does not exist
  • dev-dependencies 依存管理セクションに関するエラー
The "poetry.dev-dependencies" section is deprecated and will be removed in a future version. Use "poetry.group.dev.dependencies" instead.
  • package-mode ディレクティブに関するエラー
Error: The current project could not be installed: No file/folder found for package <開発物の名称>
If you do not want to install the current project use --no-root.
If you want to use Poetry only for dependency management but not for packaging, you can disable package mode by setting package-mode = false in your pyproject.toml file.
If you did intend to install the current project, you may need to set `packages` in your pyproject.toml file.

Discussion

コメントにはログインが必要です。