build-item 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.5
2
+ Name: build_item
3
+ Version: 0.1.1
4
+ Summary: 一个用于学习 Python 公共库构建和发布的示例工程
5
+ Requires-Python: >=3.14
6
+ Requires-Dist: markdown>=3.5
7
+ Requires-Dist: python-dateutil>=2.8
8
+ Description-Content-Type: text/markdown
9
+
10
+ # build_item
11
+
12
+ 一个用于学习 Python 公共库构建和发布的示例工程。该库提供了两个简单的函数:`start_fn` 和 `end_fn`,用于打印"开始"和"结束",可作为快速上手 `setuptools` / `hatchling` 打包流程的参考模板。
13
+
14
+ ## 功能特性
15
+
16
+ - 轻量、零配置:安装即可直接导入使用
17
+ - 提供两个入门示例函数,演示包内模块的组织与导出
18
+ - 演示标准 `src` 布局与 `pyproject.toml`(Hatchling)构建配置
19
+ - 随包引入 `python-dateutil` 和 `Markdown` 依赖,展示依赖声明方式
20
+
21
+ ## 安装
22
+
23
+ ### 通过 pip 安装(推荐)
24
+
25
+ ```bash
26
+ pip install build-item
27
+ ```
28
+
29
+ ### 从源码安装
30
+
31
+ ```bash
32
+ git clone <your-repo-url>
33
+ cd build_item
34
+ pip install .
35
+ ```
36
+
37
+ ## 快速开始
38
+
39
+ ```python
40
+ from build_item import start_fn, end_fn
41
+
42
+ start_fn() # 输出:开始
43
+ end_fn() # 输出:结束
44
+ ```
45
+
46
+ ## 使用说明
47
+
48
+ | 函数 | 说明 | 输出 |
49
+ | --------- | -------------------------- | ------ |
50
+ | `start_fn` | 打印"开始" | `开始` |
51
+ | `end_fn` | 打印"结束" | `结束` |
52
+
53
+ ### 直接通过模块路径调用
54
+
55
+ 也可以单独从子模块导入:
56
+
57
+ ```python
58
+ from build_item.start import start_fn
59
+ from build_item.end import end_fn
60
+ ```
61
+
62
+ ## 开发与构建
63
+
64
+ ### 环境准备
65
+
66
+ ```bash
67
+ python -m venv .venv
68
+ # Windows
69
+ .venv\Scripts\activate
70
+ # Linux / macOS
71
+ source .venv/bin/activate
72
+
73
+ pip install build hatchling
74
+ ```
75
+
76
+ ### 构建发行包
77
+
78
+ ```bash
79
+ python -m build
80
+ ```
81
+
82
+ 构建完成后,会在 `dist/` 目录下生成 `.whl` 和 `.tar.gz` 文件。
83
+
84
+ ### 本地验证安装
85
+
86
+ ```bash
87
+ pip install dist/build_item-0.1.1-py3-none-any.whl
88
+ python -c "from build_item import start_fn, end_fn; start_fn(); end_fn()"
89
+ ```
90
+
91
+ ### 发布到 PyPI
92
+
93
+ ```bash
94
+ pip install twine
95
+ twine upload dist/*
96
+ ```
97
+
98
+ > 发布前请先在 [PyPI](https://pypi.org/) 注册账号,并配置 `TWINE_USERNAME` / `TWINE_PASSWORD` 或使用 API Token。
99
+
100
+ ## 项目结构
101
+
102
+ ```
103
+ build_item/
104
+ ├── src/
105
+ │ └── build_item/
106
+ │ ├── __init__.py # 包入口,导出 start_fn 和 end_fn
107
+ │ ├── start/
108
+ │ │ └── __init__.py # start_fn 实现
109
+ │ └── end/
110
+ │ └── __init__.py # end_fn 实现
111
+ ├── pyproject.toml # 构建与项目配置(Hatchling)
112
+ └── README.md
113
+ ```
114
+
115
+ ## 要求
116
+
117
+ - Python >= 3.14
118
+ - 第三方依赖:`python-dateutil>=2.8`、`Markdown>=3.5`
119
+
120
+ ## 许可证
121
+
122
+ 请根据项目实际情况填写许可证(例如 MIT、Apache-2.0 等),并在 `pyproject.toml` 中同步声明 `license` 字段。
@@ -0,0 +1,113 @@
1
+ # build_item
2
+
3
+ 一个用于学习 Python 公共库构建和发布的示例工程。该库提供了两个简单的函数:`start_fn` 和 `end_fn`,用于打印"开始"和"结束",可作为快速上手 `setuptools` / `hatchling` 打包流程的参考模板。
4
+
5
+ ## 功能特性
6
+
7
+ - 轻量、零配置:安装即可直接导入使用
8
+ - 提供两个入门示例函数,演示包内模块的组织与导出
9
+ - 演示标准 `src` 布局与 `pyproject.toml`(Hatchling)构建配置
10
+ - 随包引入 `python-dateutil` 和 `Markdown` 依赖,展示依赖声明方式
11
+
12
+ ## 安装
13
+
14
+ ### 通过 pip 安装(推荐)
15
+
16
+ ```bash
17
+ pip install build-item
18
+ ```
19
+
20
+ ### 从源码安装
21
+
22
+ ```bash
23
+ git clone <your-repo-url>
24
+ cd build_item
25
+ pip install .
26
+ ```
27
+
28
+ ## 快速开始
29
+
30
+ ```python
31
+ from build_item import start_fn, end_fn
32
+
33
+ start_fn() # 输出:开始
34
+ end_fn() # 输出:结束
35
+ ```
36
+
37
+ ## 使用说明
38
+
39
+ | 函数 | 说明 | 输出 |
40
+ | --------- | -------------------------- | ------ |
41
+ | `start_fn` | 打印"开始" | `开始` |
42
+ | `end_fn` | 打印"结束" | `结束` |
43
+
44
+ ### 直接通过模块路径调用
45
+
46
+ 也可以单独从子模块导入:
47
+
48
+ ```python
49
+ from build_item.start import start_fn
50
+ from build_item.end import end_fn
51
+ ```
52
+
53
+ ## 开发与构建
54
+
55
+ ### 环境准备
56
+
57
+ ```bash
58
+ python -m venv .venv
59
+ # Windows
60
+ .venv\Scripts\activate
61
+ # Linux / macOS
62
+ source .venv/bin/activate
63
+
64
+ pip install build hatchling
65
+ ```
66
+
67
+ ### 构建发行包
68
+
69
+ ```bash
70
+ python -m build
71
+ ```
72
+
73
+ 构建完成后,会在 `dist/` 目录下生成 `.whl` 和 `.tar.gz` 文件。
74
+
75
+ ### 本地验证安装
76
+
77
+ ```bash
78
+ pip install dist/build_item-0.1.1-py3-none-any.whl
79
+ python -c "from build_item import start_fn, end_fn; start_fn(); end_fn()"
80
+ ```
81
+
82
+ ### 发布到 PyPI
83
+
84
+ ```bash
85
+ pip install twine
86
+ twine upload dist/*
87
+ ```
88
+
89
+ > 发布前请先在 [PyPI](https://pypi.org/) 注册账号,并配置 `TWINE_USERNAME` / `TWINE_PASSWORD` 或使用 API Token。
90
+
91
+ ## 项目结构
92
+
93
+ ```
94
+ build_item/
95
+ ├── src/
96
+ │ └── build_item/
97
+ │ ├── __init__.py # 包入口,导出 start_fn 和 end_fn
98
+ │ ├── start/
99
+ │ │ └── __init__.py # start_fn 实现
100
+ │ └── end/
101
+ │ └── __init__.py # end_fn 实现
102
+ ├── pyproject.toml # 构建与项目配置(Hatchling)
103
+ └── README.md
104
+ ```
105
+
106
+ ## 要求
107
+
108
+ - Python >= 3.14
109
+ - 第三方依赖:`python-dateutil>=2.8`、`Markdown>=3.5`
110
+
111
+ ## 许可证
112
+
113
+ 请根据项目实际情况填写许可证(例如 MIT、Apache-2.0 等),并在 `pyproject.toml` 中同步声明 `license` 字段。
@@ -0,0 +1,22 @@
1
+ # pyproject.toml
2
+
3
+ [build-system] # 构建系统配置,指定构建工具和依赖
4
+ requires = ["hatchling"] # 依赖的后端构建工具
5
+ build-backend = "hatchling.build" # 使用哪个工具的哪个模块来构建项目
6
+
7
+ [project] # 工程描述
8
+ name = "build_item" # 发行版名称
9
+ version = "0.1.1" # 版本号,遵循语义化版本控制
10
+ description = "一个用于学习 Python 公共库构建和发布的示例工程" # 项目简介
11
+ requires-python = ">=3.14" # 指定支持的 Python 版本
12
+ readme = "README.md" # 指定项目的 README 文件路径
13
+ dependencies = [
14
+ "python-dateutil>=2.8", # 依赖的第三方库,指定版本要求
15
+ "Markdown>=3.5", # 另一个依赖
16
+ ]
17
+
18
+ [tool.hatch.build.targets.sdist] # 配置源代码分发包
19
+ # 配置留空,表示它会默认包含所有项目文件
20
+
21
+ [tool.hatch.build.targets.wheel] # 配置 wheel 包
22
+ packages = ["src/build_item"] # 配置 wheel 包的构建目标,指定包含的包路径
@@ -0,0 +1,4 @@
1
+ from end import end_fn
2
+ from start import start_fn
3
+
4
+ __all__: list[str] = ["end_fn", "start_fn"]
@@ -0,0 +1,2 @@
1
+ def end_fn():
2
+ print("结束")
@@ -0,0 +1,2 @@
1
+ def start_fn():
2
+ print("开始")