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.
- toolkitx-0.0.2/.github/workflows/python-publish.yml +91 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/PKG-INFO +1 -1
- {toolkitx-0.0.1 → toolkitx-0.0.2}/pyproject.toml +1 -1
- toolkitx-0.0.2/toolkitx/__init__.py +26 -0
- toolkitx-0.0.2/toolkitx/lab/__init__.py +5 -0
- toolkitx-0.0.1/toolkitx/__init__.py +0 -13
- toolkitx-0.0.1/toolkitx/lab/__init__.py +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/.gitignore +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/.python-version +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/LICENSE +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/README.md +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/tests/lab/test_translator.py +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/tests/test_text_utils.py +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/toolkitx/hello.py +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/toolkitx/lab/translator.py +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/toolkitx/text_utils.py +0 -0
- {toolkitx-0.0.1 → toolkitx-0.0.2}/uv.lock +0 -0
|
@@ -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
|
|
@@ -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"
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|