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

セットアップを全面的にuvへ切り替え #121

Merged
merged 2 commits into from
Nov 4, 2024
Merged

Conversation

shimizukawa
Copy link
Member

@shimizukawa shimizukawa commented Nov 4, 2024

• pyproject.tomlファイルを新規追加し、プロジェクト依存関係の管理方法をuvに変更
• devcontaienrの設定をuv前提に更新
• Dockerfileをuv前提に更新
• GitHub Actionsワークフローをuvを使用するように変更
• READMEの説明を更新

@shimizukawa shimizukawa force-pushed the uv-ing branch 5 times, most recently from 27f9f3d to 1864cba Compare November 4, 2024 07:14
Copy link
Member Author

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

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

セルフコメント

Comment on lines +30 to +34
- 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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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}
Copy link
Member Author

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",
Copy link
Member Author

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": {},
Copy link
Member Author

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"
Copy link
Member Author

Choose a reason for hiding this comment

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

uv sync のインストール先を設定。
codespace 部分は remoteUser だけど環境変数で指定する方法が分からず直接指定。

Comment on lines +2 to +3
uv self update
uv sync
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

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

ついで。

Comment on lines +3 to +4
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
Copy link
Member Author

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に逃がす

@shimizukawa shimizukawa marked this pull request as ready for review November 4, 2024 07:30
pyproject.toml Show resolved Hide resolved
Copy link
Member Author

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

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

fix reST syntax

Copy link
Member

@usaturn usaturn left a comment

Choose a reason for hiding this comment

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

たぶん LGTM

pyproject.toml Show resolved Hide resolved
Copy link
Member

@usaturn usaturn left a comment

Choose a reason for hiding this comment

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

変更よろ

README.rst Outdated Show resolved Hide resolved
@shimizukawa shimizukawa requested a review from usaturn November 4, 2024 08:00
Copy link
Member

@usaturn usaturn left a comment

Choose a reason for hiding this comment

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

LGTM

@shimizukawa shimizukawa merged commit 22fe311 into master Nov 4, 2024
1 check passed
@shimizukawa shimizukawa deleted the uv-ing branch November 4, 2024 08:01
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.

3 participants