From 8d445b11a4b1437d14556f877eafaff691cf926f Mon Sep 17 00:00:00 2001 From: dqy <1016751306@qq.com> Date: Wed, 15 May 2024 10:40:36 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=92=B0=E5=86=99pip=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/design.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/docs/design.md b/docs/design.md index 113bbc8..4af8edf 100644 --- a/docs/design.md +++ b/docs/design.md @@ -70,6 +70,59 @@ python backdoor_detection.py ./src -o ./output/report.pdf python requirements_detection.py ./requirements.txt -o ./output/report.md ``` +## 打包 + +### 简介 + +本项目需要将 Python 代码打包成 pip 包,以便于分发和安装。以下是如何实现和使用该打包功能的详细步骤。 + +### 打包命令 + +```bash +pip install wheel +python setup.py sdist bdist_wheel +``` + +执行上述命令后,会在 dist 目录下生成 .tar.gz 和 .whl 文件。 + +### 本地安装 + +- 安装 .whl 文件: + +``` bash +pip install dist/my_project-0.1.0-py3-none-any.whl +``` + +- 安装 .tar.gz 文件: + +``` bash +pip install dist/my_project-0.1.0.tar.gz +``` + +## 上传到 PyPI + +- 安装 twine: + +``` bash +pip install twine +``` + +- 使用 twine 上传包到 PyPI: + +``` bash +twine upload dist/* +``` + +需要提供 PyPI 的用户名和密码。如果没有 PyPI 账号,可以在 PyPI 注册。 + +## 使用 PyPI 安装 + +包上传到 PyPI 后,可以通过以下命令安装: + +``` bash +pip install my_project +``` + --- ### 结论