No project description provided
Project description
Python 包发布简明流程指南
1. 准备发布环境
# 安装必要工具
pip install -U setuptools wheel twine
2. 创建项目目录结构
# 创建项目目录
mkdir mypackage
# 进入目录
cd mypackage
# 创建标准目录结构
mkdir -p mypackage data tests
touch mypackage/__init__.py
touch mypackage/main.py
touch setup.py
touch README.md
touch LICENSE
# 打开vscode
code .
标准目录结构
mypackage/
├── data/ # 数据文件目录
├── mypackage/ # 主代码包
│ ├── __init__.py # 包初始化文件
│ └── main.py # 主代码文件
├── setup.py # 包配置
├── LICENSE # 许可证文件
└── README.md # 项目文档
3. 创建核心文件
1. setup.py 配置
2. LICENSE 文件
3. README.md
4. 构建分发包
# 1. 清理旧文件
Remove-Item -Recurse -Force build, dist, *.egg-info -ErrorAction SilentlyContinue
# 2. 生成分发包
# sdist: 源码分发版 source distribution
# bdist_wheel: 构建分发版 build distribution
python setup.py sdist bdist_wheel
# 3. 验证包结构
twine check dist/*
5. 发布到 PyPI
# 断开代理后上传到PyPI
# 在终端提示输入 Enter your API token: 时,只粘贴 token 本身,不要加上 pypi- 前缀(Twine 会自动加)
twine upload dist/*
# 测试上传命令
twine upload --repository testpypi dist/*
6. 安装验证
# 从PyPI安装
pip install mypackage
# 验证安装
python -c "import mypackage; print('成功安装版本:', mypackage.__version__)"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mkfpdf-1.0.1.tar.gz
(14.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
mkfpdf-1.0.1-py3-none-any.whl
(15.1 kB
view details)
File details
Details for the file mkfpdf-1.0.1.tar.gz.
File metadata
- Download URL: mkfpdf-1.0.1.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc0463f6f36e8e4d3ae4db572d7e1641eb4bb90c5051111c2b0f84029b3c88b7
|
|
| MD5 |
6382f2618ba8a92f7bc0203de0102058
|
|
| BLAKE2b-256 |
8db1ed12e0202bc5da89268e2e442619479832dfed3c17aa6ab25304d242e4b4
|
File details
Details for the file mkfpdf-1.0.1-py3-none-any.whl.
File metadata
- Download URL: mkfpdf-1.0.1-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b03f25406a1c48777292529aa9ec203bb58a6d4223eeda0e77da2945d2bb0c24
|
|
| MD5 |
f38a81277bd29526ea9c40e052557e51
|
|
| BLAKE2b-256 |
11fbc68fb862213549b090d728721a0f06125e2a730f118f3087aea0514c1c81
|