diff --git a/README-uv.md b/README-uv.md new file mode 100644 index 0000000..6097f66 --- /dev/null +++ b/README-uv.md @@ -0,0 +1,59 @@ +# DID WBA Server with uv + +This project uses [uv](https://docs.astral.sh/uv/) as the Python package manager. + +## Prerequisites + +- Install [uv](https://docs.astral.sh/uv/) +- Python 3.9 or later + +## Setup + +1. Install Python (if not already installed): + ```bash + uv python install 3.9 + ``` + +2. Create and activate a virtual environment: + ```bash + uv venv + source .venv/bin/activate # On Windows: .venv\Scripts\activate + ``` + +3. Install dependencies: + ```bash + uv pip install -e . + ``` + +## Running the Application + +```bash +uvicorn did_server:app --reload +``` + +## Development + +- To add a new dependency: + ```bash + # 1. 安装新包 + uv pip install package_name + + # 2. 更新 pyproject.toml 中的 dependencies 列表 + + # 3. 重新安装项目依赖 + uv pip install -e . + ``` + +- To update all dependencies: + ```bash + # 更新所有包到最新版本 + uv pip install --upgrade -e . + ``` + +## Cleaning Up + +To remove the virtual environment: + +```bash +rm -rf .venv +``` diff --git a/README.md b/README.md index 5e557bd..97fa78e 100644 --- a/README.md +++ b/README.md @@ -32,19 +32,24 @@ For detailed technical documentation, please refer to [Technical Documentation]( ``` 3. Edit the .env file and set necessary configuration items -### Install Dependencies with Poetry +### Install Dependencies with uv + +[uv](https://github.com/astral-sh/uv) is an extremely fast Python package manager and resolver written in Rust. ```bash -# Create virtual environment and install dependencies with Poetry -poetry install +# Install uv (if not already installed) +curl -sSf https://astral.sh/uv/install.sh | sh -# Activate virtual environment -poetry shell +# Create and activate virtual environment +uv venv +source .venv/bin/activate # On Windows: .venv\Scripts\activate -# Or activate virtual environment this way (if it already exists) -source .venv/bin/activate +# Install project dependencies +uv pip install -e . ``` +For more uv usage instructions, please refer to the [UV Guide](README-uv.md) + ## Running the Example ### Important Note: Start the Server First, Then the Client diff --git a/README_cn.md b/README_cn.md index b93e321..5239900 100644 --- a/README_cn.md +++ b/README_cn.md @@ -30,19 +30,24 @@ ``` 3. 编辑.env文件,设置必要的配置项 -### 使用Poetry安装依赖 +### 使用 uv 安装依赖 + +[uv](https://github.com/astral-sh/uv) 是一个快速的 Python 包管理器和解析器,使用 Rust 编写。 ```bash -# 使用Poetry创建虚拟环境并安装依赖 -poetry install +# 安装 uv (如果尚未安装) +curl -sSf https://astral.sh/uv/install.sh | sh -# 激活虚拟环境 -poetry shell +# 创建并激活虚拟环境 +uv venv +source .venv/bin/activate # Windows: .venv\Scripts\activate -# 或者使用以下方式激活虚拟环境(如果已存在) -source .venv/bin/activate +# 安装项目依赖 +uv pip install -e . ``` +更多 uv 使用说明请参考 [UV 使用指南](README-uv.md) + ## 运行示例 ### 重要提示:需要先启动服务器,再启动客户端 diff --git a/pyproject.toml b/pyproject.toml index 1e2a84e..d13d1fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,32 +1,32 @@ -[tool.poetry] +[project] name = "did-wba-server" version = "0.1.0" description = "DID WBA Server Example" -authors = ["Your Name "] -packages = [ - { include = "api" }, - { include = "auth" }, - { include = "core" }, - { include = "utils" } +authors = [ + {name = "Your Name", email = "your.email@example.com"} +] +requires-python = ">=3.9" +dependencies = [ + "fastapi>=0.103.0,<1.0.0", + "uvicorn>=0.32.0,<1.0.0", + "python-dotenv>=1.0.0,<2.0.0", + "pyjwt>=2.8.0,<3.0.0", + "agent-connect>=0.3.5,<0.4.0", + "python-multipart>=0.0.6,<1.0.0", + "aiohttp>=3.8.5,<4.0.0", + "cryptography>=43.0.3,<44.0.0", + "canonicaljson>=2.0.0,<3.0.0", + "pydantic>=2.3.0,<3.0.0", + "pydantic-settings>=2.0.0,<3.0.0", + "pytest>=7.4.0,<8.0.0" ] -[tool.poetry.dependencies] -python = "^3.9" -fastapi = "^0.103.0" -uvicorn = "^0.32.0" -python-dotenv = "^1.0.0" -pyjwt = "^2.8.0" -agent-connect = "^0.3.5" -python-multipart = "^0.0.6" -aiohttp = "^3.8.5" -cryptography = "^43.0.3" -canonicaljson = "^2.0.0" -pydantic = "^2.3.0" -pydantic-settings = "^2.0.0" +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" -[tool.poetry.group.dev.dependencies] -pytest = "^7.4.0" +[tool.hatch.build] +packages = ["api", "auth", "core", "utils"] -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +[tool.hatch.build.targets.wheel] +packages = ["api", "auth", "core", "utils"]