Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poetry 1.5に更新する #710

Closed
wants to merge 6 commits into from
Closed

Conversation

aoirint
Copy link
Member

@aoirint aoirint commented Jun 24, 2023

内容

2023年5月にPoetry 1.5がリリースされました(リリースノート)。
Poetry 1.4と1.5ではlockファイルに差分が生じるため、その更新をします。

更新コマンド

poetry lock --no-update

poetry export --without-hashes -o requirements.txt
poetry export --without-hashes --with dev -o requirements-dev.txt
poetry export --without-hashes --with test -o requirements-test.txt
poetry export --without-hashes --with license -o requirements-license.txt

差分の説明: poetry.lockからのcategoryの削除

Poetry 1.5でpoetry.lockから、未使用のフィールドcategoryが削除されました(poetry add --dev pytestのような指定をしていたバージョンの名残だと思います)。
pyproject.tomlにはgroupが残っており、poetry add --group dev pytestのような指定は変わらず使えます。

未解決の課題: Poetryのバージョンを固定する

Poetryの機能としては、Poetryのバージョン固定は未実装のようです。

未解決の課題: リビジョンによってpoetry.lockの1行目に差分が生じてしまう

PR作成時点でPoetry最新安定版の1.5.1を使ってpoetry.lockの更新をしましたが、1行目にPoetryのバージョンが書き込まれるようになったようです。
開発者によって異なるリビジョンを使っていると、パッケージを変更するPRのたびに1行目に差分が生じてしまいます。
テンプレートやドキュメントで、PR作成時点で最新のPoetryを使っているかを確認することができるといいかもしれません。

関連 Issue

スクリーンショット・動画など

その他

@aoirint aoirint requested a review from a team as a code owner June 24, 2023 07:35
@aoirint aoirint requested review from Hiroshiba and removed request for a team June 24, 2023 07:35
@github-actions
Copy link

github-actions bot commented Jun 24, 2023

Coverage Result

Resultを開く
Name Stmts Miss Cover
voicevox_engine/init.py 2 1 coverage-50%
voicevox_engine/acoustic_feature_extractor.py 75 0 coverage-100%
voicevox_engine/dev/synthesis_engine/init.py 3 1 coverage-67%
voicevox_engine/dev/synthesis_engine/mock.py 36 2 coverage-94%
voicevox_engine/downloadable_library.py 93 5 coverage-95%
voicevox_engine/full_context_label.py 162 3 coverage-98%
voicevox_engine/kana_parser.py 86 1 coverage-99%
voicevox_engine/metas/Metas.py 33 0 coverage-100%
voicevox_engine/metas/MetasStore.py 29 14 coverage-52%
voicevox_engine/metas/init.py 2 0 coverage-100%
voicevox_engine/model.py 160 9 coverage-94%
voicevox_engine/mora_list.py 5 0 coverage-100%
voicevox_engine/part_of_speech_data.py 5 0 coverage-100%
voicevox_engine/preset/Preset.py 12 0 coverage-100%
voicevox_engine/preset/PresetError.py 3 1 coverage-67%
voicevox_engine/preset/PresetManager.py 81 2 coverage-98%
voicevox_engine/preset/init.py 4 0 coverage-100%
voicevox_engine/setting/Setting.py 11 0 coverage-100%
voicevox_engine/setting/SettingLoader.py 19 0 coverage-100%
voicevox_engine/setting/init.py 3 0 coverage-100%
voicevox_engine/synthesis_engine/init.py 5 0 coverage-100%
voicevox_engine/synthesis_engine/core_wrapper.py 201 159 coverage-21%
voicevox_engine/synthesis_engine/make_synthesis_engines.py 57 49 coverage-14%
voicevox_engine/synthesis_engine/synthesis_engine.py 130 11 coverage-92%
voicevox_engine/synthesis_engine/synthesis_engine_base.py 67 9 coverage-87%
voicevox_engine/user_dict.py 144 11 coverage-92%
voicevox_engine/utility/init.py 5 0 coverage-100%
voicevox_engine/utility/connect_base64_waves.py 37 0 coverage-100%
voicevox_engine/utility/core_version_utility.py 9 2 coverage-78%
voicevox_engine/utility/mutex_utility.py 11 1 coverage-91%
voicevox_engine/utility/path_utility.py 26 8 coverage-69%
TOTAL 1516 289 coverage-81%

@Hiroshiba
Copy link
Member

差分わかりやすくて助かります!!
バージョン書かれるようになったの良いですね!変な更新があった時にヒントになりそう。

実はpoetryのバージョン管理はrequirements-dev で行われてます。

poetry = "^1.3.1"

ここ更新すればreadmeでの案内は省けるかな?と思いました。(更新後にreadme更新を忘れちゃいそうなので…)

@aoirint
Copy link
Member Author

aoirint commented Jun 24, 2023

実はpoetryのバージョン管理はrequirements-dev で行われてます。

ありがとうございます! 気づいてませんでした! Poetry導入時 #535 (comment) からバージョン指定がありましたね。

Poetry 1.4.2の環境で、pyproject.toml内のpoetryバージョン制約に>=1.5を加えたところ、poetry install時にエラーになったので、バージョンの固定はこれでよさそうです!

$ poetry --version
Poetry (version 1.4.2)

$ poetry install
Creating virtualenv voicevox-engine in ****\voicevox_engine\.venv
Installing dependencies from lock file
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run `poetry lock [--no-update]` to fix it.

Because voicevox-engine depends on poetry (^1.5.1,>=1.5) which doesn't match any versions, version solving failed.

@aoirint
Copy link
Member Author

aoirint commented Jun 24, 2023

あ、 #710 (comment) のエラーはpoetry lockを実行していなかったからですね...
もう一度調べてみます

Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

更新ありがとうございます!!
1点だけコメントしました!

@@ -62,7 +62,7 @@ pyinstaller = "^5.6,<5.7.0" # NOTE: 5.7.0 or higher will fail to build the bootl
pre-commit = "^2.16.0"
atomicwrites = "^1.4.0"
colorama = "^0.4.4"
poetry = "^1.3.1"
poetry = "^1.5.1,>=1.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

,>=1.5の意図はなんでしょうか 👀
あってもなくても良いなら周りに合わせた方が好ましそうです!

Suggested change
poetry = "^1.5.1,>=1.5"
poetry = "^1.5.1"

(PRの範囲に関係ないのですが、そもそも範囲指定じゃなく単一バージョンに固定したほうが確実かも?とかちょっと思いました!)

Copy link
Member Author

@aoirint aoirint Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

開発者がPoetryを使った操作をするときに、Poetry 1.4以下を使わないようにするためですが、あんまり意味はないかもです。

バージョン1.5.xを使ってほしい場合には、~1.5.1のように1.5 <= version < 1.6を指定できます。
^1.5.1の場合、1.0 <= version < 2.0になります。
以前の指定では、1.0 <= version < 2.0だったので、1.5 <= version < 2.0に範囲を狭めました。

ちなみに、開発者がシステムにPoetryをインストールしている場合、pyproject.tomlpoetry.lockに含まれるPoetryバージョンには制限を受けなさそうです。

これらが管理するのは、poetry installpip install -r requirements-dev.txtで(venvに)インストールされるPoetryのバージョンで、開発者がvenvのPoetryを操作に使わなかった場合には影響しないと思います。

pyproject.tomlを見た開発者に、このバージョンを使ってほしいという意図を伝えることはできるかもですが、操作時にエラーを出すような形で固定できるわけではないと思います。

poetry installして(システムの)Poetryが作成した仮想環境に入れば、venvのPoetry(poetry.lockで管理されたバージョンのPoetry)が使われるようになるようなので、Poetry 1.5以上を使われやすくする効果はあると思います。

@aoirint
Copy link
Member Author

aoirint commented Oct 1, 2023

すでにmasterブランチ@10ac2f5(のpoetry.lock)は、Poetry 1.6.1(2023-10-01時点の最新版)になっていて、このPRの主題のPoetry 1.5以降への更新は達成されているので、Closeしようと思います。

このPRが止まっていたのは、Poetry自体のバージョンをリポジトリ側で確実に固定する方法について詳細を調べようとしていた点があり、
これについては解消されていないままですが、問題になるpoetry.lockの差分(開発者が使うPoetryのバージョンによって、poetry.lockの内容が若干変わる)は自動生成ファイルというのもあり、それほど問題ないんじゃないかと思っています。

一応Issue化だけしておきました。

@aoirint aoirint closed this Oct 1, 2023
@Hiroshiba
Copy link
Member

すみません、コメントを返していなかったことに今気づきました 🙇

グローバルのpoetryが使われて変なロックファイルが出来上がり得るのはちょっと何とかしたいなと感じました!
issueで詳細な議論ができればと思います 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants