simple-demo-sdk
一个用于演示 打包发布到 PyPI 的完整流程 的极简 Python SDK。
特性
SimpleClient:极简的 HTTP 客户端(基于requests),支持 Bearer Token、上下文管理器slugify(text):字符串转 URL slugchunked(iterable, size):分批迭代器- CLI 命令:
simple-demo-sdk get <url>/simple-demo-sdk slug <text>
安装
pip install simple-demo-sdk
快速开始
from simple_demo_sdk import SimpleClient, slugify, chunked
print(slugify("Hello, PyPI World!")) # -> hello-pypi-world
print(list(chunked(range(7), 3))) # -> [[0,1,2],[3,4,5],[6]]
with SimpleClient(base_url="https://httpbin.org") as client:
print(client.get("/get", params={"hello": "world"}))
本地开发
# 1. 创建虚拟环境
python -m venv .venv && source .venv/bin/activate
# 2. 可编辑安装 + 开发依赖
pip install -e ".[dev]"
# 3. 运行测试
pytest
打包与发布到 PyPI
# 1. 安装构建工具
pip install --upgrade build twine
# 2. 构建 sdist + wheel(产物在 dist/ 下)
python -m build
# 3. 检查产物
twine check dist/*
# 4. 上传到 TestPyPI(推荐先测试)
twine upload --repository testpypi dist/*
# 5. 从 TestPyPI 安装验证
pip install -i https://test.pypi.org/simple/ simple-demo-sdk
# 6. 正式上传到 PyPI
twine upload dist/*
关于凭证
推荐使用 API Token,配置 ~/.pypirc:
[distutils]
index-servers =
pypi
testpypi
[pypi]
username = __token__
password = pypi-AgEIcHlwaS5vcmc...你的 token
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-AgENdGVzdC5weXBpLm9yZw...你的 token
许可证
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tca_sdk_test-0.1.1.tar.gz
(6.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tca_sdk_test-0.1.1.tar.gz.
File metadata
- Download URL: tca_sdk_test-0.1.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7159d14522dc66f5f9a3ac996202ae32da0afaadc6fd274599412799d5ab1a13
|
|
| MD5 |
f6c6ecbd214e1b208e3b267b16071edd
|
|
| BLAKE2b-256 |
12844d8d2bf8ee4cbc61024e6278cb648e5acc1b7d9ac42ef37186aa1c339c7b
|
File details
Details for the file tca_sdk_test-0.1.1-py3-none-any.whl.
File metadata
- Download URL: tca_sdk_test-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c18fe8ef99d029490ccc9d42745735067484ad26e08d9a1070d77b76787eaf03
|
|
| MD5 |
2a58b79aee2cf0768a347d912cdc7085
|
|
| BLAKE2b-256 |
de62975dea9d34f89c24a14f2220927ece4c1b565a0410c0bfd736a8f7167758
|