feature/package-development #22
@ -70,6 +70,59 @@ python backdoor_detection.py ./src -o ./output/report.pdf
|
|||||||
python requirements_detection.py ./requirements.txt -o ./output/report.md
|
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
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 结论
|
### 结论
|
||||||
|
Loading…
x
Reference in New Issue
Block a user