Metadata-Version: 2.4
Name: uv-hello-world
Version: 0.1.7
Summary: Add your description here
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# 使用UV工具编写Tool项目

## 安装
### Linux、MacOS
使用 `curl` 下载脚本，并使用 `sh` 执行它：
```shell
curl -LsSf https://astral.sh/uv/install.sh | sh
```
如果系统中没有 `curl`，可以使用 `wget`：
```shell
wget -qO- https://astral.sh/uv/install.sh | sh
```
### Windows
使用 `irm` 下载脚本，并使用 `iex` 执行它：
```
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```
## 创建新项目
您可以使用 uv init 命令创建一个新的 Python 项目：
```shell
uv init hello-world
cd hello-world
```
或者，你可以在工作目录中初始化一个项目：
```shell
mkdir hello-world
cd hello-world
uv init
```
uv 将创建以下文件：
```shell
├── .gitignore
├── .python-version
├── README.md
├── main.py
└── pyproject.toml
```
main.py 文件包含一个简单的“Hello world”程序。使用 uv run 尝试运行它：
```shell
uv run main.py
```

## 项目结构
一个项目由几个重要的部分组成，这些部分协同工作，使 uv 能够管理你的项目。除了`uv init`创建的文件外，uv 还会创建一个虚拟环境和`uv.lock`文件。 在项目根目录下首次运行项目命令（例如：`uv run`）时，会生成一个文件。 uv sync，或 uv lock。

### 完整列表如下：
```shell
├── .venv
│   ├── bin
│   ├── lib
│   └── pyvenv.cfg
├── .python-version
├── README.md
├── main.py
├── pyproject.toml
└── uv.lock
```
### pyproject.toml
`pyproject.toml` 文件包含了关于您项目的元数据：
```shell
[project]
name = "uv-hello-world"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = []
```

## 本地运行

### uv run 运行
```shell
uv run main.py
```

### 修改项目为Tool类型
修改`pyproject.toml`项目配置,增加入口函数
```shell
[project.scripts]
uv-hello-world = "main:hello"
```
#### 使用uvx 运行
```shell
uvx --from . uv-hello-world
```

## 构建
```shell
uv build
```

## 发布到pypi
使用 `--token` 或 `UV_PUBLISH_TOKEN` 设置 PyPI 密钥
使用 `--password` 或 `UV_PUBLISH_PASSWORD`设置密码
```shell
uv publish
```
