🐍 Rye

why rye?

I want a python manage tool, with which I can use PyPI directly that I can use latest packages, and I can specify the version of python, simply to manage the virtual envs.

📦 install Rye

Linux/macOS

1
2
3
4
5
curl -sSf https://rye.astral.sh/get | bash
source ~/.rye/env
// or you can : `sudo pacman -S rye` on archlinux.


Windows (PowerShell)

1
irm https://rye.astral.sh/get.ps1 | iex

🧱 initial a project’s package

create a project and config python venv.

1
2
rye init myproject
cd myproject

select the version of python.

1
rye pin 3.10

install packages.

1
2
rye add requests
rye add pandas torch transformers # 批量添加

install packages with specified version.

1
2
3
4
5
6
7

rye add "tensorflow==2.18.0"
rye sync

#or blurred
rye add "tensorflow>=2.19.0"
rye sync

install dependencies of develop.

1
rye add --dev pytest ruff

remove dependencies.

1
rye remove requests

install from pyproject.toml.

1
rye sync

🧪 run and develop.

run .py or CLI

1
2
3
rye run python main.py
rye run pytest
rye run jupyter notebook

active venv

1
2
3
4
rye shell

// now is replaced by : `. .venv/bin/activate`


🔒 lock or unlock dependencies env

lock the dependencies(generate pyproject.lock)

1
rye lock

🧹 clean

delete the env.

1
rye sync --clean

📁 others

re-generate .venv

1
rye sync

find the python

1
rye which python

info

1
rye show

💡 VSCode

VSCode choose the explain of :

1
.your_project/.venv/bin/python

or use CLI of rye:

1
rye run code .

optional : write .toml file

we can control our project env more precisely.

for example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
[project]
name = "open-webui"
description = "Open WebUI - A modular web interface for AI applications"
authors = [
{ name = "Your Name", email = "your.email@example.com" }
]
license = { file = "LICENSE" }
readme = "README.md"
requires-python = ">=3.11,<3.13"
dynamic = ["version"]

classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]

dependencies = [
# Core Web Framework
"fastapi==0.115.7",
"uvicorn[standard]==0.34.0",
"starlette-compress==1.6.0",
"python-multipart==0.0.20",
"pydantic==2.10.6",

# Authentication & Security
"python-jose==3.4.0",
"passlib[bcrypt]==1.7.4",
"PyJWT[crypto]==2.10.1",
"argon2-cffi==23.1.0",
"authlib==1.4.1",

# Database & Storage
"sqlalchemy==2.0.38",
"alembic==1.14.0",
"psycopg2-binary==2.9.9",
"pgvector==0.4.0",
"pymongo>=4.0",
"redis>=4.0",
"boto3==1.35.53",

# AI/ML Providers
"openai>=1.0",
"anthropic>=0.3",
"google-generativeai==0.8.5",
"tiktoken>=0.5.0",
"transformers>=4.35.0",
"sentence-transformers==4.1.0",
"accelerate>=0.25.0",

# Vector Databases
"chromadb==0.6.3",
"qdrant-client~=1.12.0",
"pinecone==6.0.2",

# File Processing
"pypdf==4.3.1",
"unstructured==0.16.17",
"pillow==11.1.0",
"opencv-python-headless==4.11.0.86",

# Utilities
"loguru==0.7.3",
"psutil>=5.9.0",
"python-socketio==5.13.0",
"docker>=7.1.0",
]

[tool.rye]
managed = true
dev-dependencies = [
"black==25.1.0",
"pytest==8.3.2",
"pytest-docker==3.1.1",
"moto[s3]>=5.0.26", # For mocking AWS services
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project.scripts]
open-webui = "open_webui.main:start_app"

[tool.hatch.version]
path = "package.json"
pattern = '"version": "(.*)"'
keyword function instance
[project] project name none
description description for model “a modular for …”
authors info of authors {name = “ABC”}…
license license you use {file = “path or SPDX”}
readme README.md none
requires-python the python version the project accept “>=3.11, <3.13”
dependencies the info of packages we need [“fastapi==0.115.7”, “next one”]
classifiers PyPI’s classifier… none
[tool.rye] configuration for rye none
managed use rye or not none
dev-dependencies the env we need for development [“black==25.1.0”, “next one”]
[build-system] config of build none
requires tool of build [“hatchling”]
build-backend backend model path “hatchling.build”
[project.scripts] defind command line “open_webui.main:start_app”
[tool.hatch.version] dynamic version manage none
path version num source “package.json”
pattern extract num ‘“version”:”(.*)”‘

in the last

we can also use uv…