bstart-trb 0.1.0__tar.gz → 0.2.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 @@
1
+ 3.11
@@ -0,0 +1,117 @@
1
+ # Building Guide
2
+
3
+ This guide explains how to build `bstart-trb` wheel packages for distribution.
4
+
5
+ ## Prerequisites
6
+
7
+ ### Windows
8
+
9
+ 1. **Install MSYS2** (provides gfortran):
10
+ - Download from https://www.msys2.org/
11
+ - After installation, open MSYS2 terminal and run:
12
+ ```bash
13
+ pacman -S mingw-w64-ucrt-x86_64-gcc-fortran
14
+ ```
15
+ - Add `C:\msys64\ucrt64\bin` to your system PATH
16
+
17
+ 2. **Install Python 3.10+**:
18
+ - Download from https://www.python.org/downloads/
19
+
20
+ 3. **Install uv** (recommended):
21
+ ```powershell
22
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
23
+ ```
24
+
25
+ ### macOS
26
+
27
+ ```bash
28
+ # Install gfortran
29
+ brew install gfortran
30
+
31
+ # Install uv
32
+ curl -LsSf https://astral.sh/uv/install.sh | sh
33
+ ```
34
+
35
+ ### Linux
36
+
37
+ ```bash
38
+ # Install gfortran
39
+ sudo apt install gfortran # Debian/Ubuntu
40
+ sudo yum install gcc-gfortran # RHEL/CentOS
41
+
42
+ # Install uv
43
+ curl -LsSf https://astral.sh/uv/install.sh | sh
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Build Steps
49
+
50
+ ### 1. Clone the repository
51
+
52
+ ```bash
53
+ git clone https://github.com/youjunxiaji/bstart-trb.git
54
+ cd bstart-trb
55
+ ```
56
+
57
+ ### 2. Install dependencies with uv
58
+
59
+ ```bash
60
+ uv sync
61
+ ```
62
+
63
+ This automatically creates a virtual environment and installs all dependencies.
64
+
65
+ ### 3. Build the wheel
66
+
67
+ ```bash
68
+ uv run python -m build --wheel
69
+ ```
70
+
71
+ The wheel file will be created in the `dist/` directory.
72
+
73
+ ---
74
+
75
+ ## Alternative: Direct f2py Build
76
+
77
+ If meson build fails, you can compile the Fortran module directly:
78
+
79
+ ```bash
80
+ cd slice_wrapper
81
+ uv run python -m numpy.f2py -c taper_slice.f90 -m _taper_slice
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Publishing to PyPI
87
+
88
+ ### 1. Install twine
89
+
90
+ ```bash
91
+ uv pip install twine
92
+ ```
93
+
94
+ ### 2. Create PyPI API token
95
+
96
+ 1. Log in to https://pypi.org
97
+ 2. Go to Account settings → API tokens → Add API token
98
+ 3. Save the token securely
99
+
100
+ ### 3. Upload the wheel
101
+
102
+ ```bash
103
+ uv run twine upload dist/*.whl
104
+ ```
105
+
106
+ When prompted:
107
+ - Username: `__token__`
108
+ - Password: Your API token (starts with `pypi-`)
109
+
110
+ ---
111
+
112
+ ## Notes
113
+
114
+ - Each Python version (3.10, 3.11, 3.12) needs a separate wheel
115
+ - Windows wheels have `.whl` suffix like `*-win_amd64.whl`
116
+ - macOS wheels: `*-macosx_*_arm64.whl` (Apple Silicon) or `*-macosx_*_x86_64.whl` (Intel)
117
+ - Linux wheels: `*-manylinux*.whl`
@@ -0,0 +1,208 @@
1
+ # bstart-trb PyPI 包配置总结
2
+
3
+ ## 完成的工作
4
+
5
+ ### 1. 包配置 (`pyproject.toml`)
6
+
7
+ ✅ **配置内容**:
8
+ - 包名:`bstart-trb`
9
+ - 版本:`0.1.0`
10
+ - 描述:Cylindrical/Tapered Roller Bearing Slice Stress Calculation Module
11
+ - Python 版本:>= 3.12
12
+ - 许可证:MIT
13
+ - 依赖:仅 `numpy >= 2.0.0`
14
+
15
+ ✅ **构建配置**:
16
+ - 使用 `hatchling` 作为构建后端
17
+ - 仅打包 `slice_wrapper` 目录
18
+ - 包含预编译的二进制文件(`.pyd`)
19
+ - 排除 Fortran 源码(`.f90`)和构建脚本(`build.py`)
20
+
21
+ ### 2. 文件修改
22
+
23
+ ✅ **新增文件**:
24
+ - `README_PYPI.md` - PyPI 包说明文档(英文)
25
+ - `PUBLISHING.md` - 发布指南(中文)
26
+ - `test_install.py` - 安装测试脚本
27
+ - `PACKAGE_SUMMARY.md` - 本文件
28
+
29
+ ✅ **修改文件**:
30
+ - `pyproject.toml` - 完整的包配置
31
+ - `.gitignore` - 允许跟踪 `.pyd` 文件
32
+ - `slice_wrapper/__init__.py` - 版本号改为 0.1.0
33
+
34
+ ✅ **添加到 Git**:
35
+ - `slice_wrapper/_taper_slice.cp312-win_amd64.pyd` - 预编译的 Fortran 模块
36
+
37
+ ### 3. 构建和测试
38
+
39
+ ✅ **构建结果**:
40
+ ```
41
+ dist/
42
+ ├── bstart_trb-0.1.0-py3-none-any.whl # Wheel 包
43
+ └── bstart_trb-0.1.0.tar.gz # 源码包
44
+ ```
45
+
46
+ ✅ **包内容验证**:
47
+ - ✅ Python 源码文件
48
+ - ✅ 预编译的 `.pyd` 文件(139 KB)
49
+ - ✅ 类型提示文件(`.pyi`)
50
+ - ✅ LICENSE 文件
51
+ - ❌ Fortran 源码(已排除)
52
+ - ❌ 构建脚本(已排除)
53
+
54
+ ✅ **功能测试**:
55
+ ```
56
+ [OK] 包版本: 0.1.0
57
+ [OK] Fortran 模块可用: True
58
+ [OK] 收敛: True
59
+ [OK] 错误码: 0
60
+ [OK] 滚子变形: 0.006387 mm
61
+ [OK] 平衡载荷: 1338.12 N
62
+ [OK] 最大应力: 1299 MPa
63
+ [SUCCESS] 所有测试通过!
64
+ ```
65
+
66
+ ## 包的特点
67
+
68
+ ### ✅ 优点
69
+
70
+ 1. **无需编译**:用户安装时不需要 Fortran 编译器
71
+ 2. **开箱即用**:pip 安装后立即可用
72
+ 3. **保密源码**:不包含 Fortran 源代码
73
+ 4. **类型安全**:完整的类型提示
74
+ 5. **体积小**:仅约 150 KB
75
+
76
+ ### ⚠️ 限制
77
+
78
+ 1. **平台限制**:当前只支持 Windows x64
79
+ 2. **Python 版本**:仅支持 Python 3.12
80
+ 3. **扩展性**:添加新平台需要重新编译
81
+
82
+ ## 安装和使用
83
+
84
+ ### 用户安装
85
+
86
+ ```bash
87
+ pip install bstart-trb
88
+ ```
89
+
90
+ ### 快速开始
91
+
92
+ ```python
93
+ from slice_wrapper import (
94
+ slice_stress,
95
+ RollerParams,
96
+ RacewayParams,
97
+ CrownType,
98
+ RacewayType,
99
+ )
100
+
101
+ # 定义参数
102
+ roller = RollerParams(
103
+ d1=10.0, d2=10.0, length=9.6,
104
+ crown_type=CrownType.LOGARITHMIC,
105
+ curve_q=14100.0
106
+ )
107
+
108
+ raceway = RacewayParams(
109
+ diameter=-150.0,
110
+ raceway_type=RacewayType.OUTER
111
+ )
112
+
113
+ # 计算
114
+ result = slice_stress(roller, raceway, load=1340.86, n_slice=30)
115
+ print(f"Max stress: {result.max_stress:.0f} MPa")
116
+ ```
117
+
118
+ ## 发布流程
119
+
120
+ ### 1. 测试 PyPI(推荐)
121
+
122
+ ```bash
123
+ # 上传到测试环境
124
+ uv run twine upload --repository testpypi dist/*
125
+
126
+ # 测试安装
127
+ pip install --index-url https://test.pypi.org/simple/ \
128
+ --extra-index-url https://pypi.org/simple/ bstart-trb
129
+ ```
130
+
131
+ ### 2. 生产 PyPI
132
+
133
+ ```bash
134
+ # 上传到生产环境
135
+ uv run twine upload dist/*
136
+ ```
137
+
138
+ ### 3. Git 标签
139
+
140
+ ```bash
141
+ git commit -m "v0.1.0 发布到 PyPI"
142
+ git tag v0.1.0
143
+ git push origin main --tags
144
+ ```
145
+
146
+ ## 后续工作
147
+
148
+ ### 可选优化
149
+
150
+ 1. **多平台支持**:
151
+ - 在 Linux 上编译 `.so` 文件
152
+ - 在 macOS 上编译 `.so` 文件
153
+ - 上传多个平台特定的 wheel
154
+
155
+ 2. **多 Python 版本**:
156
+ - 在 Python 3.11, 3.13 等版本下编译
157
+ - 上传多个版本特定的 wheel
158
+
159
+ 3. **CI/CD**:
160
+ - 设置 GitHub Actions 自动构建
161
+ - 自动测试和发布
162
+
163
+ 4. **文档**:
164
+ - 添加 Sphinx 文档
165
+ - 发布到 Read the Docs
166
+
167
+ ## 文件清单
168
+
169
+ ### 项目根目录
170
+ ```
171
+ bstart-trb/
172
+ ├── slice_wrapper/ # 主包目录
173
+ │ ├── __init__.py # 包初始化(版本 0.1.0)
174
+ │ ├── models.py # 数据模型
175
+ │ ├── wrapper.py # Python 包装器
176
+ │ ├── _taper_slice.pyi # 类型提示
177
+ │ ├── py.typed # PEP 561 标记
178
+ │ ├── _taper_slice.cp312-win_amd64.pyd # 预编译模块 ⭐
179
+ │ ├── taper_slice.f90 # Fortran 源码(不打包)
180
+ │ └── build.py # 构建脚本(不打包)
181
+ ├── dist/ # 构建产物
182
+ │ ├── bstart_trb-0.1.0-py3-none-any.whl
183
+ │ └── bstart_trb-0.1.0.tar.gz
184
+ ├── pyproject.toml # 包配置 ⭐
185
+ ├── README_PYPI.md # PyPI 说明 ⭐
186
+ ├── PUBLISHING.md # 发布指南 ⭐
187
+ ├── test_install.py # 测试脚本 ⭐
188
+ ├── PACKAGE_SUMMARY.md # 本文件 ⭐
189
+ ├── LICENSE # MIT 许可证
190
+ ├── .gitignore # Git 忽略(已修改)⭐
191
+ └── uv.lock # 依赖锁定
192
+
193
+ ⭐ = 新增或重要修改的文件
194
+ ```
195
+
196
+ ## 参考文档
197
+
198
+ - **用户文档**:`README_PYPI.md`
199
+ - **发布指南**:`PUBLISHING.md`
200
+ - **构建文档**:`BUILDING.md`
201
+ - **原始说明**:`README.md`(中文技术文档)
202
+
203
+ ## 联系方式
204
+
205
+ - 作者:Gu Lei
206
+ - 许可证:MIT
207
+ - Python 版本:>= 3.12
208
+ - 平台:Windows x64
@@ -1,26 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bstart-trb
3
- Version: 0.1.0
4
- Summary: Cylindrical/Tapered Roller Bearing Slice Stress Calculation Module
5
- Project-URL: Homepage, https://github.com/yourusername/bstart-trb
6
- Project-URL: Repository, https://github.com/yourusername/bstart-trb
7
- Project-URL: Documentation, https://github.com/yourusername/bstart-trb#readme
8
- Author-email: Gu Lei <gulei@example.com>
9
- License: MIT
3
+ Version: 0.2.1
4
+ Summary: Add your description here
10
5
  License-File: LICENSE
11
- Keywords: bearing,contact,f2py,fortran,hertz,roller,stress
12
- Classifier: Development Status :: 4 - Beta
13
- Classifier: Intended Audience :: Manufacturing
14
- Classifier: Intended Audience :: Science/Research
15
- Classifier: License :: OSI Approved :: MIT License
16
- Classifier: Operating System :: Microsoft :: Windows
17
- Classifier: Programming Language :: Fortran
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.12
20
- Classifier: Topic :: Scientific/Engineering
21
- Classifier: Topic :: Scientific/Engineering :: Physics
22
- Requires-Python: >=3.12
6
+ Requires-Python: >=3.11
23
7
  Requires-Dist: numpy>=2.0.0
8
+ Provides-Extra: demo
9
+ Requires-Dist: openpyxl>=3.1.5; extra == 'demo'
10
+ Requires-Dist: pandas>=2.0.0; extra == 'demo'
11
+ Requires-Dist: plotly>=5.0.0; extra == 'demo'
24
12
  Description-Content-Type: text/markdown
25
13
 
26
14
  # BSTART-TRB
@@ -48,7 +36,7 @@ pip install bstart-trb
48
36
  ## Quick Start
49
37
 
50
38
  ```python
51
- from slice_wrapper import (
39
+ from bstart_trb import (
52
40
  slice_stress,
53
41
  RollerParams,
54
42
  RacewayParams,
@@ -135,7 +123,7 @@ The method is more accurate than simplified Hertz formulas as it accounts for:
135
123
 
136
124
  ## Requirements
137
125
 
138
- - Python >= 3.12
126
+ - Python >= 3.11
139
127
  - NumPy >= 2.0.0
140
128
 
141
129
  ## Platform Support
@@ -0,0 +1,224 @@
1
+ # PyPI 发布指南
2
+
3
+ 本文档介绍如何将 `bstart-trb` 包发布到 PyPI。
4
+
5
+ ## 准备工作
6
+
7
+ ### 1. 确保代码已更新并测试通过
8
+
9
+ ```bash
10
+ # 运行测试
11
+ uv run python test_install.py
12
+ ```
13
+
14
+ ### 2. 更新版本号
15
+
16
+ 编辑以下两个文件中的版本号:
17
+ - `pyproject.toml` - 第 3 行的 `version`
18
+ - `slice_wrapper/__init__.py` - 最后一行的 `__version__`
19
+
20
+ 版本号格式:`major.minor.patch`
21
+ - **major**: 重大功能更新或不兼容的 API 变更
22
+ - **minor**: 新增功能或模块(向下兼容)
23
+ - **patch**: Bug 修复、代码优化、小改动
24
+
25
+ 示例:
26
+ ```
27
+ 0.1.0 -> 0.1.1 (Bug 修复)
28
+ 0.1.1 -> 0.2.0 (新增功能)
29
+ 0.2.0 -> 1.0.0 (重大更新)
30
+ ```
31
+
32
+ ### 3. 确保 `.pyd` 文件是最新的
33
+
34
+ 如果修改了 Fortran 代码,需要重新编译:
35
+
36
+ ```bash
37
+ cd slice_wrapper
38
+ uv run python build.py
39
+ ```
40
+
41
+ ## 构建包
42
+
43
+ ### 1. 清理旧的构建产物
44
+
45
+ ```bash
46
+ Remove-Item -Path "dist" -Recurse -Force -ErrorAction SilentlyContinue
47
+ ```
48
+
49
+ ### 2. 构建 wheel 和 sdist
50
+
51
+ ```bash
52
+ uv build
53
+ ```
54
+
55
+ 这将在 `dist/` 目录下生成两个文件:
56
+ - `bstart_trb-{version}-py3-none-any.whl` - wheel 包(包含预编译的 .pyd)
57
+ - `bstart_trb-{version}.tar.gz` - 源码发行版
58
+
59
+ ### 3. 验证构建的包
60
+
61
+ 检查 wheel 内容:
62
+ ```bash
63
+ python -m zipfile -l dist\bstart_trb-{version}-py3-none-any.whl
64
+ ```
65
+
66
+ 确认包含以下文件:
67
+ - ✅ `slice_wrapper/__init__.py`
68
+ - ✅ `slice_wrapper/models.py`
69
+ - ✅ `slice_wrapper/wrapper.py`
70
+ - ✅ `slice_wrapper/_taper_slice.pyi`
71
+ - ✅ `slice_wrapper/py.typed`
72
+ - ✅ `slice_wrapper/_taper_slice.cp312-win_amd64.pyd` ← **重要!预编译的二进制文件**
73
+ - ❌ `taper_slice.f90` - **应该被排除**
74
+ - ❌ `build.py` - **应该被排除**
75
+
76
+ ## 发布到 PyPI
77
+
78
+ ### 1. 注册 PyPI 账号
79
+
80
+ - 生产环境:https://pypi.org/account/register/
81
+ - 测试环境:https://test.pypi.org/account/register/
82
+
83
+ ### 2. 创建 API Token
84
+
85
+ 1. 登录 PyPI
86
+ 2. 进入账户设置 -> API tokens
87
+ 3. 创建新的 token(选择 "Entire account" 或指定项目)
88
+ 4. 保存 token(只显示一次!)
89
+
90
+ ### 3. 配置 twine
91
+
92
+ 创建 `~/.pypirc` 文件(Windows: `C:\Users\{用户名}\.pypirc`):
93
+
94
+ ```ini
95
+ [distutils]
96
+ index-servers =
97
+ pypi
98
+ testpypi
99
+
100
+ [pypi]
101
+ username = __token__
102
+ password = pypi-AgEIcHlwaS5vcmcC...你的token...
103
+
104
+ [testpypi]
105
+ repository = https://test.pypi.org/legacy/
106
+ username = __token__
107
+ password = pypi-AgENdGVzdC5weXBpLm9yZwI...你的token...
108
+ ```
109
+
110
+ **注意**:将 `.pypirc` 添加到 `.gitignore`,不要提交到 Git!
111
+
112
+ ### 4. 上传到测试 PyPI(推荐先测试)
113
+
114
+ ```bash
115
+ uv run twine upload --repository testpypi dist/*
116
+ ```
117
+
118
+ 测试安装:
119
+ ```bash
120
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ bstart-trb
121
+ ```
122
+
123
+ ### 5. 上传到生产 PyPI
124
+
125
+ 确认测试无误后:
126
+
127
+ ```bash
128
+ uv run twine upload dist/*
129
+ ```
130
+
131
+ ## 发布后
132
+
133
+ ### 1. 测试安装
134
+
135
+ ```bash
136
+ # 在新的虚拟环境中测试
137
+ pip install bstart-trb
138
+ ```
139
+
140
+ ### 2. 创建 Git 标签
141
+
142
+ ```bash
143
+ git add pyproject.toml slice_wrapper/__init__.py
144
+ git commit -m "v0.1.0 发布到 PyPI"
145
+ git tag v0.1.0
146
+ git push origin main --tags
147
+ ```
148
+
149
+ ### 3. 创建 GitHub Release(可选)
150
+
151
+ 1. 前往 GitHub 仓库的 "Releases" 页面
152
+ 2. 点击 "Create a new release"
153
+ 3. 选择刚才创建的标签
154
+ 4. 编写 Release Notes
155
+ 5. 附加构建的 wheel 文件
156
+
157
+ ## 常见问题
158
+
159
+ ### Q: 如何支持多个 Python 版本?
160
+
161
+ A: 当前包只包含 Python 3.12 的编译文件(`cp312`)。如需支持其他版本:
162
+ 1. 在不同 Python 版本下重新编译 `.pyd` 文件
163
+ 2. 将所有 `.pyd` 文件添加到 `slice_wrapper/` 目录
164
+ 3. 重新构建包
165
+
166
+ ### Q: 如何支持 Linux 和 macOS?
167
+
168
+ A: 需要在对应平台上编译:
169
+ 1. 在 Linux 上运行 `python build.py`,生成 `.so` 文件
170
+ 2. 在 macOS 上运行 `python build.py`,生成 `.so` 文件
171
+ 3. 将所有编译文件添加到包中
172
+ 4. 重新构建并上传
173
+
174
+ ### Q: 上传失败:文件已存在
175
+
176
+ A: PyPI 不允许覆盖已发布的版本。解决方案:
177
+ 1. 递增版本号(如 0.1.0 -> 0.1.1)
178
+ 2. 重新构建并上传
179
+
180
+ ### Q: 用户安装后提示找不到 Fortran 模块
181
+
182
+ A: 检查:
183
+ 1. 用户的 Python 版本是否为 3.12(当前只支持 3.12)
184
+ 2. 用户的操作系统是否为 Windows x64
185
+ 3. 包是否正确包含了 `.pyd` 文件
186
+
187
+ ## 自动化发布(高级)
188
+
189
+ 可以使用 GitHub Actions 自动发布:
190
+
191
+ ```yaml
192
+ # .github/workflows/publish.yml
193
+ name: Publish to PyPI
194
+
195
+ on:
196
+ release:
197
+ types: [published]
198
+
199
+ jobs:
200
+ deploy:
201
+ runs-on: windows-latest
202
+ steps:
203
+ - uses: actions/checkout@v3
204
+ - uses: actions/setup-python@v4
205
+ with:
206
+ python-version: '3.12'
207
+ - name: Install dependencies
208
+ run: |
209
+ pip install uv
210
+ uv pip install hatchling twine
211
+ - name: Build package
212
+ run: uv build
213
+ - name: Publish to PyPI
214
+ env:
215
+ TWINE_USERNAME: __token__
216
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
217
+ run: uv run twine upload dist/*
218
+ ```
219
+
220
+ ## 参考链接
221
+
222
+ - [PyPI 官方文档](https://packaging.python.org/tutorials/packaging-projects/)
223
+ - [Twine 文档](https://twine.readthedocs.io/)
224
+ - [PEP 517 构建系统](https://peps.python.org/pep-0517/)