From 32221cbaa77179a2a156fe2261bf2540692cc81a Mon Sep 17 00:00:00 2001 From: "Kaz Saita(raspi5)" Date: Mon, 22 Jul 2024 11:30:14 +0900 Subject: [PATCH] sync notes(auto) --- content/20240722101442 Rye.md | 119 ++++++++++++++++++++++++++++++++++ content/20240722104422 uv.md | 6 +- 2 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 content/20240722101442 Rye.md diff --git a/content/20240722101442 Rye.md b/content/20240722101442 Rye.md new file mode 100644 index 0000000..4a3df22 --- /dev/null +++ b/content/20240722101442 Rye.md @@ -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: +- 今のところ無い \ No newline at end of file diff --git a/content/20240722104422 uv.md b/content/20240722104422 uv.md index de18e59..56102e2 100644 --- a/content/20240722104422 uv.md +++ b/content/20240722104422 uv.md @@ -3,7 +3,5 @@ #python #package uvはpipの代替で高速に動作する。 - -以下WIP - -[GitHub - astral-sh/uv: An extremely fast Python package installer and resolver, written in Rust.](https://github.com/astral-sh/uv) \ No newline at end of file +[GitHub - astral-sh/uv: An extremely fast Python package installer and resolver, written in Rust.](https://github.com/astral-sh/uv) +自分のユースケースでは、これ単体で使うことはあまり無く、[[Rye]]が内部的に使っている。 \ No newline at end of file