Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Pythonのパッケージマネージャー「uv」
Search
Masafumi Abeta
October 30, 2024
Programming
450
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Pythonのパッケージマネージャー「uv」
Masafumi Abeta
October 30, 2024
More Decks by Masafumi Abeta
See All by Masafumi Abeta
GPTモデルでキャラクター設定する際の課題
abeta
0
390
GPTをLINEで使えるようにして布教した
abeta
0
220
【Nishika】プリント基板の電子部品検出
abeta
0
360
初心者向けChatGPT入門
abeta
0
290
GPT Short Talk
abeta
0
180
拡散モデルについて少しだけ
abeta
0
97
動的計画モデル
abeta
0
210
物体追跡
abeta
0
360
特徴量記述
abeta
0
230
Other Decks in Programming
See All in Programming
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
0
130
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
200
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
670
Built Our Own Background Agent at LayerX
layerx
PRO
9
5.1k
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.4k
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
160
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.6k
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
450
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
340
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
460
源内ハンズオン概要編
hideg
0
150
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
950
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
460
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.4k
So, you think you're a good person
axbom
PRO
2
2.1k
Speed Design
sergeychernyshev
33
2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
590
Design in an AI World
tapps
1
280
Code Review Best Practice
trishagee
74
20k
sira's awesome portfolio website redesign presentation
elsirapls
0
320
Color Theory Basics | Prateek | Gurzu
gurzu
0
410
Building Adaptive Systems
keathley
44
3.2k
Transcript
Pythonのパッケージマネージャー「uv」 阿部田将史 – Masafumi Abeta 2024.10.30
© 2024 Masafumi Abeta 2 uvとは Pythonの バージョン管理 仮想環境作成 パッケージ管理
pip ✓ venv ✓ pyenv ✓ Pipenv ✓ ✓ Poetry ✓ ✓ conda ✓ ✓ ✓ uv ✓ ✓ ✓ https://github.com/astral-sh/uv
© 2024 Masafumi Abeta 3 # On macOS and Linux.
$ curl -LsSf https://astral.sh/uv/install.sh | sh # On Windows. $ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" # With pip. $ pip install uv # Update $ uv self update $ uv --version uv 0.4.27 uvのインストール
© 2024 Masafumi Abeta 4 $ uv python install 3.10
3.11 3.12 Searching for Python versions matching: Python 3.10 Searching for Python versions matching: Python 3.11 Searching for Python versions matching: Python 3.12 Installed 3 versions in 3.42s + cpython-3.10.14-macos-aarch64-none + cpython-3.11.9-macos-aarch64-none + cpython-3.12.4-macos-aarch64-none Pythonのインストール
© 2024 Masafumi Abeta 5 $ uv init sample --package
--python 3.12 プロジェクトの作成 sample ├── .git ├── .gitignore ├── .python-version ├── README.md ├── pyproject.toml └── src └── sample └── __init__.py [project] name = "sample" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [] [project.scripts] sample = "sample:main" [build-system] requires = ["hatchling"] build-backend = "hatchling.build" pyproject.toml
© 2024 Masafumi Abeta 6 $ cd sample $ uv
venv 仮想環境の作成 sample ├── .git ├── .gitignore ├── .python-version ├── .venv ├── README.md ├── pyproject.toml └── src └── sample └── __init__.py
© 2024 Masafumi Abeta 7 $ uv run example.py 3.12.6
$ uv run --python 3.10 example.py 3.10.15 スクリプト実行 import sys print(".".join(map(str, sys.version_info[:3]))) example.py
© 2024 Masafumi Abeta 8 $ uv add requests $
uv remove requests # アンインストール $ uv add flake8 --dev # 開発用インストール パッケージのインストール sample ├── .git ├── .gitignore ├── .python-version ├── .venv ├── README.md ├── pyproject.toml ├── src │ └── sample │ └── __init__.py └── uv.lock [project] name = "sample" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [ "requests>=2.32.3", ] [dependency-groups] dev = [ "flake8>=7.1.1", ] [project.scripts] sample = "sample:main" [build-system] requires = ["hatchling"] build-backend = "hatchling.build" pyproject.toml
© 2024 Masafumi Abeta 9 $ uv sync # pyproject.tomlの依存関係をインストール
$ uv lock # uv.lockファイルを作成 パッケージのインストール2
© 2024 Masafumi Abeta 10 $ uv tree Resolved 6
packages in 1ms sample v0.1.0 └── requests v2.32.3 ├── certifi v2024.8.30 ├── charset-normalizer v3.4.0 ├── idna v3.10 └── urllib3 v2.2.3 依存関係の表示
© 2024 Masafumi Abeta 11 $ uv pip install ruff
Resolved 1 package in 43ms Installed 1 package in 1ms + ruff==0.7.1 ただしuvの管理から外れてしまう pip インターフェース(最後の手段) [project] name = "sample" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [ "requests>=2.32.3", ] [project.scripts] sample = "sample:main" [build-system] requires = ["hatchling"] build-backend = "hatchling.build" pyproject.toml Pyproject.toml にもuv.lockに も反映されない
© 2024 Masafumi Abeta 12 右のように書き換えてからsyncコマンド $ uv sync PyTorchのインストール
(--index-urlの追加) [project] name = "sample" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [ "requests>=2.32.3", "torch==2.5.1+121" ] ~省略~ [tool.uv.source] torch = { index = "pytorch" } [[tool.uv.index]] name = "pytorch" url = "hrrps://dounload.pytorch.org/whl/cu121" explict = true pyproject.toml
© 2024 Masafumi Abeta 13 $ uv venv $ source
.venv/bin/activate $ uv sync $ uv run mim install mmengine $ uv run mim install "mmcv==2.1.0" $ git clone https://github.com/open-mmlab/mmdetection.git $ cd mmdetection $ uv pip install -v -e . $ uv run demo/image_demo.py demo/demo.jpg rtmdet-s (例)MMDetectionのインストール [project] name = “sample" version = "0.1.0" description = "Add your description here" readme = "README.md" requires-python = "==3.10.12" dependencies = [ "wheel>=0.44.0", "numpy==1.26.4", "torch==2.1.2+cu121", "openmim", "setuptools>=75.3.0", "importlib-metadata>=8.5.0", "platformdirs>=4.3.6", ] [tool.uv.sources] torch = { index = "pytorch" } [[tool.uv.index]] name = "pytorch" url = "https://download.pytorch.org/whl/cu121" explicit = true pyproject.toml
© 2024 Masafumi Abeta 14 その他できること • パッケージのビルド • CLIツールのインストール
他にもあるので公式をチェック https://docs.astral.sh/uv/ 良いところ • Pythonのバージョン管理ができる • パッケージ管理ができる • パッケージの依存関係まで分かる • 動作がめっちゃ速い 不足に感じるところ • editableモード等、複雑なインストールに対応していない(機械学習PJではありがち) • インストール順があるものは対応できない(flash-attention) • 開発が活発なので仕様が大きく変わるかも(3日に一回パッチアップデート) まとめ
15 END