blankcx330-hello
一个用于学习 Python 公共库构建与发布 全流程的示例工程:从源码组织、
pyproject.toml 配置,到 python -m build 打包、twine 上传 PyPI,
再到 pip install 安装使用。
简介
blankcx330-hello 演示一个最小可发布的 Python 包应该长什么样:
- 采用
src布局,源码与工程配置分离,避免脚本和缓存被误打进发行包; - 使用 hatchling 作为构建后端,全部配置集中在
pyproject.toml; - 同时产出 sdist(
.tar.gz)与 wheel(.whl)两种分发格式。
包本身只做一件事:打印一句问候语。价值不在功能,而在于把这套流程完整跑通一遍。
环境要求
- Python >= 3.14
安装
pip install blankcx330-hello
发行名
blankcx330-hello和导入名blankcx330_hello不一样:PyPI 上带连字符,import时连字符会变成下划线,这是 Python 模块名的正常约定。
从源码以开发模式安装:
git clone <你的仓库地址>
cd blankcx330-hello
python -m venv .venv
. .venv/Scripts/Activate.ps1 # Windows PowerShell
# source .venv/bin/activate # macOS / Linux
pip install -e .
快速开始
from blankcx330_hello import hello
hello()
输出:
你好,这是一个包里面的函数
API
blankcx330_hello.hello()
打印一句固定的问候语,不接受参数,返回 None。
| 名称 | 签名 | 说明 |
|---|---|---|
hello |
() -> None |
在标准输出打印问候语 |
项目结构
blankcx330-hello/
├── pyproject.toml # 构建系统与项目元数据
├── README.md
└── src/
├── main.py # 本地演示脚本,不随包发布
└── blankcx330_hello/
├── __init__.py # 对外导出 hello
└── hello.py # 具体实现
构建与发布
python -m build # 产物生成到 dist/
python -m twine check dist/* # 校验元数据与 README 渲染
python -m twine upload dist/* # 需要 PyPI API Token
许可证
MIT
Metadata
Release files for blankcx330-hello 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| blankcx330_hello-0.1.4.tar.gz | 2.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| blankcx330_hello-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.2 kB
Release files / blankcx330_hello-0.1.4.tar.gz
| Download URL | blankcx330_hello-0.1.4.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12630086daf98f608ee8592df5ac40f9c9e7f442294bd381720c0a77a70baae4
|
|
BLAKE2b-256 checksum How to use checksums |
698b150ebe8f7fca5de6d019d82597eb266003fb6e6979ebd817b6f4c8f0a757
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.1
|
Release files / blankcx330_hello-0.1.4-py3-none-any.whl
| Download URL | blankcx330_hello-0.1.4-py3-none-any.whl |
|---|---|
| Size | 2.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a7ba4ed7abee85bbf5c1a451270ea6e5e9e9e5426af064c503181b32eefb6ef
|
|
BLAKE2b-256 checksum How to use checksums |
056c2307a3f0e617fafd78f29958409eec20dfcae3a25d34d81a57fd09192638
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.1
|
Security for blankcx330-hello 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.