Metadata-Version: 2.4
Name: myteamtest
Version: 0.1.0
Summary: 一个可通过 pip install 安装的 Python 工具包示例工程
Author-email: Your Name <you@example.com>
License: MIT
Project-URL: Homepage, https://github.com/yourname/myteamtest
Project-URL: Issues, https://github.com/yourname/myteamtest/issues
Keywords: example,toolkit,template
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Dynamic: license-file

# myteamtest

一个**可通过 `pip install` 安装**的 Python 工具包示例工程。
采用现代 `pyproject.toml` + `src` 布局，开箱即用，可直接改名后作为你自己的包发布到 PyPI。

## 目录结构

```
myteamtest/
├── pyproject.toml          # 唯一的构建/元数据配置文件（替代 setup.py + setup.cfg）
├── README.md
├── LICENSE
├── .gitignore
├── src/
│   └── myteamtest/
│       ├── __init__.py     # 对外导出的 API
│       ├── core.py         # 核心功能
│       ├── utils.py        # 辅助工具
│       ├── cli.py          # 命令行入口
│       └── py.typed        # 标记该包带类型提示
├── tests/
│   ├── test_core.py
│   ├── test_utils.py
│   └── test_cli.py
└── .github/workflows/ci.yml
```

> 使用 `src/` 布局的好处：导入时用的是**安装后的包**而不是当前目录的源码，
> 能提前暴露"漏声明的子包""忘记加依赖"这类只在用户机器上才会炸的问题。

## 快速开始

```bash
# 1. 创建虚拟环境（推荐）
python -m venv .venv
.venv\Scripts\activate        # Windows
# source .venv/bin/activate   # Linux / macOS

# 2. 可编辑安装（改代码立即生效，适合开发）
pip install -e ".[dev]"

# 3. 跑测试
pytest

# 4. 试用命令行（由 [project.scripts] 生成）
myteamtest --help
myteamtest count README.md -n 5
myteamtest size 1048576
# 也支持管道
echo "hello hello world" | myteamtest count
```

## 作为库使用

```python
from myteamtest import word_count, human_readable_size, Timer, chunked

word_count("Hello hello world", top_n=2)   # {'hello': 2, 'world': 1}
human_readable_size(1536)                  # '1.50 KB'

with Timer() as t:
    ...
print(t.elapsed)
```

## 打包与安装

```bash
pip install build twine

# 构建（生成 dist/myteamtest-0.1.0-py3-none-any.whl 和 .tar.gz）
python -m build

# 本地验证 wheel 能装能用
pip install dist/myteamtest-0.1.0-py3-none-any.whl
python -c "import myteamtest; print(myteamtest.__version__)"
```

## 发布到 PyPI

```bash
# 1. 先发到测试环境演练
twine upload --repository testpypi dist/*
pip install --index-url https://test.pypi.org/simple/ myteamtest

# 2. 正式发布（需要 PyPI Token）
twine upload dist/*
```

### Windows 一键发布

```powershell
$env:TWINE_USERNAME = "__token__"
$env:TWINE_PASSWORD = "pypi-你的API令牌"
.\publish.ps1                 # 正式发布
.\publish.ps1 -TestPyPI       # 先演练到 TestPyPI
```

发布前检查清单：

- [ ] `pyproject.toml` 里 `version` 已递增
- [ ] `name` 在 PyPI 上未被占用
- [ ] `python -m build` 与 `twine check dist/*` 均通过
- [ ] `pytest` 全绿

## 改成你自己的包

1. 把目录 `src/myteamtest/` 重命名为 `src/<你的包名>/`
2. 全局替换 `myteamtest` → `<你的包名>`（`pyproject.toml`、`cli.py`、`tests/`、本文件）
3. 修改 `pyproject.toml` 中的 `authors`、`urls`、`description`
4. 重新 `pip install -e .`

## 常用命令备忘

| 目的 | 命令 |
| --- | --- |
| 开发安装 | `pip install -e ".[dev]"` |
| 运行测试 | `pytest` |
| 覆盖率 | `pytest --cov=myteamtest --cov-report=term-missing` |
| 代码检查 | `ruff check src tests` |
| 构建分发包 | `python -m build` |
| 上传 PyPI | `twine upload dist/*` |

## 许可证

MIT
