-
Notifications
You must be signed in to change notification settings - Fork 16
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
セットアップを全面的にuvへ切り替え #121
セットアップを全面的にuvへ切り替え #121
Conversation
27f9f3d
to
1864cba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
セルフコメント
- name: Install the latest version of uv | ||
uses: astral-sh/setup-uv@v3 | ||
with: | ||
path: | | ||
~/.cache/pip | ||
~/.local/ | ||
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ steps.get-date.outputs.yyyymm }} | ||
version: "latest" | ||
enable-cache: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pip3 freeze | ||
echo "python version $(uv run python --version) running" | ||
echo "uv version $(uv --version) running" | ||
uv sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv sync の実行速度(キャッシュなし)
$ rm -Rf ~/.local
$ rm -Rf ~/.cache/uv
$ time uv sync
real 0m1.535s
user 0m1.102s
sys 0m0.868s
run: | | ||
echo "python version $(python3 --version) running" | ||
echo "pip version $(pip3 --version) running" | ||
python3 -m pip install -U pip setuptools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pip installの実行速度(キャッシュ無し)
$ rm -Rf ~/.cache/pip
$ python -m venv venv
$ source venv/bin/activate
$ time pip install -r requirements.txt
real 0m1.535s
user 0m1.102s
sys 0m0.868s
|
||
uv venv --allow-existing ~/.local | ||
uv pip install --prefix ~/.local/ -r requirements.txt | ||
uv venv --allow-existing ${UV_PROJECT_ENVIRONMENT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.local をPython環境として使うためvenvで上書き
"ghcr.io/devcontainers/features/git:1": {}, | ||
}, | ||
"name": "Default Linux Universal", | ||
"image": "mcr.microsoft.com/devcontainers/universal:2-linux", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
デフォルトイメージを利用。
github codespacesでキャッシュされていて速いので。
(devcontainer使う人はだいたいcodespacesでしょう、という前提)
}, | ||
"name": "Default Linux Universal", | ||
"image": "mcr.microsoft.com/devcontainers/universal:2-linux", | ||
"features": {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
デフォルトイメージにはgitがデフォルトで同梱されているため、追加インストールなし
|
||
"onCreateCommand": "bash .devcontainer/on_create_command.sh" | ||
"containerEnv": { | ||
"UV_PROJECT_ENVIRONMENT": "/home/codespace/.local" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv sync のインストール先を設定。
codespace
部分は remoteUser
だけど環境変数で指定する方法が分からず直接指定。
uv self update | ||
uv sync |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devcontainer起動時にuv自体の更新と、インストールパッケージを最新化
@@ -1,13 +1,28 @@ | |||
FROM python:3.8-slim | |||
FROM python:3.12-slim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ついで。
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
--mount=type=cache,target=/var/lib/apt,sharing=locked \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apt cacheを後から消すのではなく、cacheをdocker cacheに逃がす
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix reST syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たぶん LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
変更よろ
Co-authored-by: Go.YAMADA <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
• pyproject.tomlファイルを新規追加し、プロジェクト依存関係の管理方法をuvに変更
• devcontaienrの設定をuv前提に更新
• Dockerfileをuv前提に更新
• GitHub Actionsワークフローをuvを使用するように変更
• READMEの説明を更新