sync notes(auto)
This commit is contained in:
parent
734d29abaf
commit
32221cbaa7
2 changed files with 121 additions and 4 deletions
119
content/20240722101442 Rye.md
Normal file
119
content/20240722101442 Rye.md
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
# 20240722101442 Rye
|
||||||
|
#tech #python
|
||||||
|
|
||||||
|
## Rye?
|
||||||
|
|
||||||
|
Ryeはpythonのプロジェクトとかパッケージをいい感じに管理してくれるやつ。 [[20231129211719 poetry|poetry]] と近い(けどこっちの方がよさそうな感触)
|
||||||
|
|
||||||
|
[Rye](https://rye.astral.sh/)
|
||||||
|
|
||||||
|
関連ツール的なものに、
|
||||||
|
- [[20240722104422 uv]]
|
||||||
|
- [[20240722104428 Ruff]]
|
||||||
|
がある。どれもastralという社が開発しているようだ。
|
||||||
|
|
||||||
|
[Astral: Next-gen Python tooling](https://astral.sh/)
|
||||||
|
|
||||||
|
|
||||||
|
## インストール
|
||||||
|
|
||||||
|
### windows
|
||||||
|
公式サイト [Rye](https://rye.astral.sh/) から.exeをダウンロードして実行。
|
||||||
|
|
||||||
|
```
|
||||||
|
Welcome to Rye!
|
||||||
|
|
||||||
|
Rye has detected that it's not installed on this computer yet and
|
||||||
|
automatically started the installer for you. For more information
|
||||||
|
read https://rye.astral.sh/guide/installation/
|
||||||
|
|
||||||
|
This installer will install rye to C:\Users\saita\.rye
|
||||||
|
This path can be changed by exporting the RYE_HOME environment variable.
|
||||||
|
|
||||||
|
Details:
|
||||||
|
Rye Version: 0.37.0
|
||||||
|
Platform: windows (x86_64)
|
||||||
|
```
|
||||||
|
|
||||||
|
途中で聞かれる質問には
|
||||||
|
```
|
||||||
|
✔ What should running `python` or `python3` do when you are not inside a Rye managed project? · Run the old default Python (provided by your OS, pyenv, etc.)
|
||||||
|
```
|
||||||
|
以外は全てデフォルトにしておいた(まだ信用していない)。
|
||||||
|
|
||||||
|
インストールが終了すると、自動でパスが通って使えるようになっていた。
|
||||||
|
|
||||||
|
### linux
|
||||||
|
wslのubuntuで試した。
|
||||||
|
```
|
||||||
|
curl -sSf https://rye.astral.sh/get | bash
|
||||||
|
This script will automatically download and install rye (latest) for you.
|
||||||
|
######################################################################## 100.0%
|
||||||
|
Welcome to Rye!
|
||||||
|
|
||||||
|
This installer will install rye to /home/kazbo/.rye
|
||||||
|
This path can be changed by exporting the RYE_HOME environment variable.
|
||||||
|
|
||||||
|
Details:
|
||||||
|
Rye Version: 0.37.0
|
||||||
|
Platform: linux (x86_64)
|
||||||
|
|
||||||
|
✔ Continue? · yes
|
||||||
|
✔ Select the preferred package installer · uv (fast, recommended)
|
||||||
|
✔ What should running `python` or `python3` do when you are not inside a Rye managed project? · Run the old default Python (provided by your OS, pyenv, etc.)
|
||||||
|
Installed binary to /home/kazbo/.rye/shims/rye
|
||||||
|
Bootstrapping rye internals
|
||||||
|
Downloading cpython@3.12.4
|
||||||
|
Checking checksum
|
||||||
|
Unpacking
|
||||||
|
Downloaded cpython@3.12.4
|
||||||
|
Updated self-python installation at /home/kazbo/.rye/self
|
||||||
|
|
||||||
|
The rye directory /home/kazbo/.rye/shims was not detected on PATH.
|
||||||
|
It is highly recommended that you add it.
|
||||||
|
✔ Should the installer add Rye to PATH via .profile? · yes
|
||||||
|
Added to PATH.
|
||||||
|
note: for this to take effect you will need to restart your shell or run this manually:
|
||||||
|
|
||||||
|
source "$HOME/.rye/env"
|
||||||
|
|
||||||
|
For more information read https://rye.astral.sh/guide/installation/
|
||||||
|
|
||||||
|
All done!
|
||||||
|
```
|
||||||
|
|
||||||
|
## プロジェクト作成(executable)
|
||||||
|
自分の場合、実行できるスクリプトを作る方が多い。とりあえずその方法(`--script`を除けば空のテンプレートができる)
|
||||||
|
|
||||||
|
[Basics - Rye](https://rye.astral.sh/guide/basics/) に書かれている。
|
||||||
|
```
|
||||||
|
rye init --script [project名]
|
||||||
|
```
|
||||||
|
ってやるとフォルタが作られる。
|
||||||
|
```
|
||||||
|
rye init
|
||||||
|
```
|
||||||
|
だけだとカレントディレクトリに必要なファイルが作られる。
|
||||||
|
|
||||||
|
```
|
||||||
|
rye sync
|
||||||
|
```
|
||||||
|
を実行すると、フォルダ内に自動的にローカルなpythonの実行環境(.venv)が作成される。cf. [[venv]]
|
||||||
|
|
||||||
|
実行するには、プロジェクトのディレクトリ内で、
|
||||||
|
```
|
||||||
|
rye run [project名]
|
||||||
|
```
|
||||||
|
とやればよい。
|
||||||
|
|
||||||
|
|
||||||
|
## poetryとの比較
|
||||||
|
|
||||||
|
poetry 1.8.2くらいとの比較。
|
||||||
|
|
||||||
|
pros:
|
||||||
|
- デフォルトでローカルフォルダに .venvを作ってくれる
|
||||||
|
- 実行可能スクリプトのプロジェクトがオマケじゃない感がある
|
||||||
|
|
||||||
|
cons:
|
||||||
|
- 今のところ無い
|
|
@ -3,7 +3,5 @@
|
||||||
#python #package
|
#python #package
|
||||||
|
|
||||||
uvはpipの代替で高速に動作する。
|
uvはpipの代替で高速に動作する。
|
||||||
|
[GitHub - astral-sh/uv: An extremely fast Python package installer and resolver, written in Rust.](https://github.com/astral-sh/uv)
|
||||||
以下WIP
|
自分のユースケースでは、これ単体で使うことはあまり無く、[[Rye]]が内部的に使っている。
|
||||||
|
|
||||||
[GitHub - astral-sh/uv: An extremely fast Python package installer and resolver, written in Rust.](https://github.com/astral-sh/uv)
|
|
Loading…
Reference in a new issue