toolkitx 0.0.1__tar.gz → 0.0.2__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,91 @@
1
+ name: Python Package CI/CD
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - '**' # 在推送到任何分支时运行测试
7
+ tags:
8
+ - 'v*' # 在推送版本标签 (例如 v0.1.0) 时触发发布
9
+ pull_request:
10
+ branches:
11
+ - main # 在向 main 分支发起 Pull Request 时运行测试
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ python-version: ["3.12"] # 与 pyproject.toml 中的 requires-python = ">=3.12" 对齐
19
+
20
+ steps:
21
+ - name: Checkout repository
22
+ uses: actions/checkout@v4
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v5
26
+ with:
27
+ # Install a specific version of uv.
28
+ version: "0.7.3"
29
+
30
+ - name: "Set up Python"
31
+ uses: actions/setup-python@v5
32
+ with:
33
+ python-version-file: ".python-version"
34
+
35
+ - name: Install the project
36
+ run: uv sync --locked --all-extras --dev
37
+
38
+ - name: Run tests with pytest
39
+ run: |
40
+ pytest
41
+
42
+ - name: Run tests
43
+ # For example, using `pytest`
44
+ run: uv run pytest tests
45
+
46
+ publish:
47
+ needs: test # 确保测试通过后才发布
48
+ runs-on: ubuntu-latest
49
+ # 仅在推送 'v*' 格式的标签时运行
50
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
51
+
52
+ permissions:
53
+ # 对于受信任的发布 (Trusted Publishing) 至 PyPI,此权限是必需的
54
+ id-token: write
55
+ contents: read # 检出仓库需要
56
+
57
+ steps:
58
+ - name: Checkout repository
59
+ uses: actions/checkout@v4
60
+
61
+ - name: Install uv
62
+ uses: astral-sh/setup-uv@v5
63
+ with:
64
+ # Install a specific version of uv.
65
+ version: "0.7.3"
66
+
67
+ - name: "Set up Python"
68
+ uses: actions/setup-python@v5
69
+ with:
70
+ python-version-file: ".python-version"
71
+
72
+ - name: Install the project
73
+ run: uv sync --locked --all-extras --dev
74
+
75
+ - name: Build
76
+ run: uv build
77
+
78
+ - name: Publish
79
+ run: uv publish --token ${{ secrets.PYPI_API_TOKEN }}
80
+
81
+
82
+ - name: Create GitHub Release (Optional)
83
+ uses: softprops/action-gh-release@v2
84
+ if: success() # 仅在发布成功时创建 Release
85
+ with:
86
+ token: ${{ secrets.GITHUB_TOKEN }} # Actions 自动提供此 token
87
+ tag_name: ${{ github.ref_name }} # 使用当前的 tag 名称
88
+ name: Release ${{ github.ref_name }}
89
+ # body_path: CHANGELOG.md # 可选:如果您的项目有 CHANGELOG.md,可以用它填充发布说明
90
+ draft: false
91
+ prerelease: false
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolkitx
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: A personal Python toolkit for common tasks
5
5
  Project-URL: Homepage, https://github.com/ider-zh/toolkitx
6
6
  Project-URL: Bug Tracker, https://github.com/ider-zh/toolkitx/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "toolkitx"
3
- version = "0.0.1"
3
+ version = "0.0.2"
4
4
  description = "A personal Python toolkit for common tasks"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -0,0 +1,26 @@
1
+ # 从子模块导入,使其可以直接从 toolkitx 包导入
2
+ from .hello import hello
3
+ from .text_utils import truncate_text_smart, split_text_by_word_count
4
+ from . import lab
5
+
6
+ # 定义 __all__,当用户使用 from toolkitx import * 时,会导入这些符号
7
+ __all__ = [
8
+ "hello",
9
+ "truncate_text_smart",
10
+ "split_text_by_word_count",
11
+ "lab",
12
+ ]
13
+
14
+ import importlib.metadata
15
+
16
+ try:
17
+ # 这将从已安装包的元数据中读取版本号
18
+ # 包名 "toolkitx" 与 pyproject.toml 中的 name 一致
19
+ __version__ = importlib.metadata.version("toolkitx")
20
+ except importlib.metadata.PackageNotFoundError:
21
+ # 如果包尚未安装(例如,在未执行 editable install 的源码状态下运行),则会发生此错误。
22
+ # 在开发初期,或者在当前环境尚未执行 `pip install -e .` 时可能会遇到。
23
+ # 构建系统 (Hatchling) 在构建包时会使用 pyproject.toml 中的版本。
24
+ # 一旦安装(即使是可编辑模式安装),importlib.metadata.version 应该能正常工作。
25
+ # 对于未安装状态,可以设置一个占位符版本。
26
+ __version__ = "0.0.0.dev0" # 或者 "unknown"
@@ -0,0 +1,5 @@
1
+ from .translator import Translator
2
+
3
+ __all__ = [
4
+ "Translator"
5
+ ]
@@ -1,13 +0,0 @@
1
- # 从子模块导入,使其可以直接从 toolkitx 包导入
2
- from .hello import hello
3
- from .text_utils import truncate_text_smart, split_text_by_word_count
4
-
5
- # 定义 __all__,当用户使用 from toolkitx import * 时,会导入这些符号
6
- __all__ = [
7
- "hello",
8
- "truncate_text_smart",
9
- "split_text_by_word_count"
10
- ]
11
-
12
- # 你也可以在这里定义包级别的版本号等元数据
13
- __version__ = "0.0.1" # 与 pyproject.toml 中的 version 一致
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes