Skip to main content

build_item

一个用于学习 Python 公共库构建和发布的示例工程。该库提供了两个简单的函数:start_fn 和 end_fn,用于打印"开始"和"结束",可作为快速上手 setuptools / hatchling 打包流程的参考模板。

功能特性

  • 轻量、零配置:安装即可直接导入使用
  • 提供两个入门示例函数,演示包内模块的组织与导出
  • 演示标准 src 布局与 pyproject.toml(Hatchling)构建配置
  • 随包引入 python-dateutil 和 Markdown 依赖,展示依赖声明方式

安装

通过 pip 安装(推荐)

pip install build-item

从源码安装

git clone <your-repo-url>
cd build_item
pip install .

快速开始

from build_item import start_fn, end_fn

start_fn()  # 输出:开始
end_fn()    # 输出:结束

使用说明

函数 说明 输出
start_fn 打印"开始" 开始
end_fn 打印"结束" 结束

直接通过模块路径调用

也可以单独从子模块导入:

from build_item.start import start_fn
from build_item.end import end_fn

开发与构建

环境准备

python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux / macOS
source .venv/bin/activate

pip install build hatchling

构建发行包

python -m build

构建完成后,会在 dist/ 目录下生成 .whl 和 .tar.gz 文件。

本地验证安装

pip install dist/build_item-0.1.1-py3-none-any.whl
python -c "from build_item import start_fn, end_fn; start_fn(); end_fn()"

发布到 PyPI

pip install twine
twine upload dist/*

发布前请先在 PyPI 注册账号,并配置 TWINE_USERNAME / TWINE_PASSWORD 或使用 API Token。

项目结构

build_item/
├── src/
│   └── build_item/
│       ├── __init__.py      # 包入口,导出 start_fn 和 end_fn
│       ├── start/
│       │   └── __init__.py  # start_fn 实现
│       └── end/
│           └── __init__.py  # end_fn 实现
├── pyproject.toml           # 构建与项目配置(Hatchling)
└── README.md

要求

  • Python >= 3.14
  • 第三方依赖:python-dateutil>=2.8、Markdown>=3.5

许可证

请根据项目实际情况填写许可证(例如 MIT、Apache-2.0 等),并在 pyproject.toml 中同步声明 license 字段。

Metadata

Release files for build-item 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for build-item 0.1.2
File Size Uploaded Provenance Actions
build_item-0.1.2.tar.gz 2.3 kB Without provenance Details for build_item-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for build-item 0.1.2
File Interpreter ABI Platform Actions
build_item-0.1.2-py3-none-any.whl Python 3 none any Details for build_item-0.1.2-py3-none-any.whl

Total release size: 5.1 kB

Release files / build_item-0.1.2.tar.gz

Download URL build_item-0.1.2.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f040b3fa063101fb77ef4d2410e140b4f238ec2803eed0cbc5f3745b4d0c80cc
BLAKE2b-256 checksum
How to use checksums
befc35ab03149b78c836e86df3d78dba411132d4e7386eb70e8ca2a1b7f3b220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.1

Release files / build_item-0.1.2-py3-none-any.whl

Download URL build_item-0.1.2-py3-none-any.whl
Size 2.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52382cdffccd52398b816918cd97cac02b5bef01b0f54aa0d1ccea448624b289
BLAKE2b-256 checksum
How to use checksums
b6f4b9541bb932ab8036de4b11e01d2d565371f1df5e5ae47f3f45293de9a801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.1

Security for build-item 0.1.2

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page