Open8

python package manager uvの調査メモ

schumi543schumi543

1st impressionはcargoに寄せてて速いというイメージ
あと互換性重視して uv pipというinterface 残してくれているのはありがたいなーと思ってた。https://docs.astral.sh/uv/getting-started/features/#the-pip-interface

公式による機能ハイライトは以下
https://docs.astral.sh/uv/#highlights

🚀 A single tool to replace pip, pip-tools, pipx, poetry, pyenv, virtualenv, and more.
⚡️ 10-100x faster than pip.
🐍 Installs and manages Python versions.
🛠️ Runs and installs Python applications.
❇️ Runs scripts, with support for inline dependency metadata.
🗂️ Provides comprehensive project management, with a universal lockfile.
🔩 Includes a pip-compatible interface for a performance boost with a familiar CLI.
🏢 Supports Cargo-style workspaces for scalable projects.
💾 Disk-space efficient, with a global cache for dependency deduplication.
⏬ Installable without Rust or Python via curl or pip.
🖥️ Supports macOS, Linux, and Windows.

schumi543schumi543

0.3.0で追加された機能について見ていく

projects

uv initでdirectory作成もできる。これは個人toolだとtemplate使ってmakeで抽象化したいからあんまり使わないかも
https://docs.astral.sh/uv/guides/projects/

uv venvの話もここにあったほうがdoc導線的にはわかりやすいかもと思った

tool

https://docs.astral.sh/uv/guides/tools/

uvxでnpx と同じようなことができる。
よく使うtoolであれば, uv tool install すると再利用しやすい。

昔pipx で雑に入れたやつを再整理できそう。

script

https://docs.astral.sh/uv/guides/scripts/

poetry runとかと一緒そう

python

python自体のinstall, uvがpythonに依存してないのでややこしくなりにくい
https://docs.astral.sh/uv/guides/install-python/

pyenv localと似たようなpython のlocal version指定は uv venv --python https://docs.astral.sh/uv/concepts/python-versions/#managed-and-system-python-installations

anyenvでpyenv管理してたのどうするか問題はあるが, toolの発展性でいうとこちら使うかな
昔ほど複数環境頻繁に切り替えるわけでもないのでこちらのI/Fに馴染んでもそんなに困らない

感想

pipx, pyenv, poetryなど複数toolで実現されていたものが集約されるのはよさそう。
あとtoolがpythonに依存してないのも良い
個人用のtemplateは置き換えて, いくつかのrepoで試して運用してみる。