Metadata-Version: 2.4
Name: neverlib
Version: 0.3.1
Summary: A successful sign for python setup
Author-email: "Never.Ling" <1786088386@qq.com>
License: MIT
Project-URL: Homepage, https://www.cnblogs.com/LXP-Never
Project-URL: Bug Tracker, https://github.com/yourusername/neverlib/issues
Project-URL: Documentation, https://github.com/yourusername/neverlib
Project-URL: Source Code, https://github.com/yourusername/neverlib
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lazy-loader>=0.4
Provides-Extra: analysis
Requires-Dist: numpy; extra == "analysis"
Requires-Dist: scipy; extra == "analysis"
Requires-Dist: tqdm; extra == "analysis"
Requires-Dist: joblib; extra == "analysis"
Requires-Dist: noisereduce; extra == "analysis"
Provides-Extra: io
Requires-Dist: soundfile; extra == "io"
Requires-Dist: pydub; extra == "io"
Provides-Extra: plot
Requires-Dist: matplotlib; extra == "plot"
Provides-Extra: vad
Requires-Dist: torch; extra == "vad"
Requires-Dist: torchaudio; extra == "vad"
Requires-Dist: librosa; extra == "vad"
Requires-Dist: webrtcvad; extra == "vad"
Requires-Dist: funasr; extra == "vad"
Requires-Dist: openai-whisper; extra == "vad"
Requires-Dist: transformers; extra == "vad"
Provides-Extra: gpu
Requires-Dist: GPUtil; extra == "gpu"
Provides-Extra: all
Requires-Dist: neverlib[analysis]; extra == "all"
Requires-Dist: neverlib[io]; extra == "all"
Requires-Dist: neverlib[plot]; extra == "all"
Requires-Dist: neverlib[vad]; extra == "all"
Requires-Dist: neverlib[gpu]; extra == "all"
Dynamic: license-file

# NeverLib

一个用于音频处理和VAD(语音活动检测)的Python工具库. 

## 安装

### 基本安装

```bash
pip install neverlib
```

### 安装带有VAD功能的版本

```bash
pip install neverlib[vad]
```

### 安装带有GPU支持的版本

```bash
pip install neverlib[gpu]
```

### 安装所有功能

```bash
pip install neverlib[all]
```

## 开发环境配置

### Pre-commit 代码格式化

本项目使用 `pre-commit` 在 git commit 时自动格式化 Python 代码.

**安装步骤**（首次开发时执行一次）：

```bash
# 1. 安装 pre-commit 工具
pip install pre-commit

# 2. 在仓库中安装 git hooks
cd /data01/never/Desktop/neverlib
pre-commit install
```

**工作方式**：

安装后，每次执行 `git commit` 时会自动执行以下任务：

**1. 代码格式化（autopep8）**
- ✅ 自动修复空格问题（`a+b` → `a + b`）
- ✅ 自动修复缩进问题（统一 4 空格）
- ✅ 自动修复空行问题（函数间 2 个空行）
- ✅ 删除行尾空格
- ✅ 长行自动换行（最大 150 字符）

**2. 自动生成 `__init__.py` 文件**
- ✅ 当 `neverlib/` 目录下的 `.py` 文件有变化时自动触发
- ✅ 扫描所有子包，提取模块导出项（包括全大写常量，如 `EPS`）
- ✅ 生成懒加载版本的 `__init__.py`（支持 IDE 补全）
- ✅ 智能跳过：只在内容真的改变时才写入文件

**正确的提交工作流**：

```bash
# 1. 添加修改的文件
git add your_files

# 2. 第一次提交（可能失败，这是正常的）
git commit -m "your message"

# 3. 如果 pre-commit 提示 "files were modified by this hook"
#    说明文件被自动格式化了，需要重新添加
git add -u  # 添加所有已跟踪文件的修改

# 4. 再次提交（通常会成功）
git commit -m "your message"
```

**说明**：
- `git add -u` 只添加已跟踪文件的修改，不会误添加新文件（如 `.env`、密钥等）
- 如果第二次提交仍然失败，检查是否有语法错误或其他问题
- pre-commit 修改文件是为了确保代码风格一致，这是正常行为

**手动检查所有文件**（可选）：

```bash
pre-commit run --all-files
```

配置文件位于 `.pre-commit-config.yaml`.

## 使用示例

```python
import neverlib

# 使用VAD功能
from neverlib import vad

# 使用工具函数
from neverlib import utils

# 发送邮件
from neverlib.message import seed_QQEmail
```

## 发布到 PyPI

### 1. 配置 PyPI 认证（首次发布）

创建 `~/.pypirc` 文件（用户 home 目录下）：

```ini
[distutils]
index-servers =
    pypi
    testpypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = __token__
password = pypi-AgEI...你的token...

[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-AgEI...你的token...
```

设置文件权限：

```bash
chmod 600 ~/.pypirc
```

**获取 PyPI Token**：
1. 登录 [PyPI](https://pypi.org/) 或 [TestPyPI](https://test.pypi.org/)
2. 进入 Account settings → API tokens
3. 创建新 token，复制到 `~/.pypirc`

### 2. 更新版本号

编辑 `pyproject.toml`，更新 `version` 字段：

```toml
[project]
name = "neverlib"
version = "x.y.z"  # 修改这里
```

版本号规范：
- **补丁版本**（Bug 修复）：`0.3.1` → `0.3.2`
- **次版本**（新功能）：`0.3.2` → `0.4.0`
- **主版本**（重大变更）：`0.4.0` → `1.0.0`

### 3. 构建发布包

```bash
# 安装构建工具（首次需要）
pip install build twine

# 清理旧的构建文件
rm -rf dist/ build/ *.egg-info

# 构建源码包和wheel包
python -m build
```

### 4. 上传到 PyPI

**先上传到 TestPyPI 测试**（推荐）：

```bash
python -m twine upload --repository testpypi dist/*
```

测试安装：

```bash
pip install --index-url https://test.pypi.org/simple/ neverlib
```

**确认无误后，上传到正式 PyPI**：

```bash
python -m twine upload dist/*
```

### 5. 验证发布

```bash
# 等待几分钟后
pip install --upgrade neverlib

# 验证版本
python -c "import neverlib; print(neverlib.__version__)"
```

### 常见问题

**Q: 提示 "File already exists"**
A: 该版本号已存在，需要更新 `setup.py` 中的版本号

**Q: 提示 "Invalid or non-existent authentication"**
A: 检查 `~/.pypirc` 中的 token 是否正确

**Q: 上传时需要输入密码**
A: 确认 `~/.pypirc` 在用户 home 目录（`~/.pypirc`），而不是项目目录

## TODO List
- [ ]  客观指标添加 [DNSMOSPro ](https://github.com/fcumlin/DNSMOSPro)
- [ ]  github界面的自我介绍
- [ ]  https://github.com/nathanhaigh/parallel-rsync


## 许可证

本项目采用MIT许可证. 详情请参阅LICENSE文件. 

## 作者

凌逆战 | Never

博客：https://www.cnblogs.com/LXP-Never
