代码上传
This commit is contained in:
114
使用手册.md
Normal file
114
使用手册.md
Normal file
@@ -0,0 +1,114 @@
|
||||
# APP打包步骤
|
||||
|
||||
|
||||
|
||||
## 一、复制APP
|
||||
|
||||
将要打包的APP复制粘贴到根目录
|
||||
|
||||
|
||||
|
||||
## 二、编辑APP下面的apps.py文件
|
||||
|
||||
在apps.py文件中添加该函数:
|
||||
|
||||
```python
|
||||
def ready(self):
|
||||
"""Django 应用启动时的钩子。
|
||||
在此执行运行时授权校验,未授权则抛出异常阻止应用启动。
|
||||
"""
|
||||
try:
|
||||
from .license_verifier import verify_machine_license
|
||||
verify_machine_license()
|
||||
except Exception:
|
||||
# 直接再抛出,让 Django 启动失败并展示错误信息
|
||||
raise
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 三、迁移license
|
||||
|
||||
1. 将根目录下面的license_verifier.py复制粘贴到要打包的APP下
|
||||
|
||||
2. 修改license_verifier.py文件
|
||||
|
||||
将下面的PACKAGE_NAME的值改为要把包的app名称
|
||||
|
||||
```
|
||||
PACKAGE_NAME = "hertz_studio_django_xxxxx"
|
||||
```
|
||||
|
||||
修改该脚本最后一行代码,将Xxxxx改为打包的app简称:
|
||||
|
||||
```
|
||||
raise RuntimeError("Hertz Xxxxx license verification failed")
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 四、修改MANIFEST.in文件
|
||||
|
||||
将下面的hertz_studio_django_xxx改为打包的app名称
|
||||
|
||||
```
|
||||
# 包含二进制文件
|
||||
recursive-include hertz_studio_django_xxx *.py
|
||||
recursive-include hertz_studio_django_xxx/migrations *.py
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 五、修改根目录下面的setup.py文件
|
||||
|
||||
- 修改成要打包的app名称(将hertz_studio_django_xxx改为打包的app名称)
|
||||
|
||||
```
|
||||
package_name = 'hertz_studio_django_xxx'
|
||||
```
|
||||
|
||||
- 将XXX改为app简称
|
||||
|
||||
```
|
||||
print("欢迎使用 Hertz System xxx!")
|
||||
```
|
||||
|
||||
- 更改下载的项目地址(将hertz_studio_django_xxx改为打包的app名称)
|
||||
|
||||
```
|
||||
url="http://hzgit.hzsystems.cn/hertz_studio_django/hertz_studio_django_xxx", # 项目地址
|
||||
```
|
||||
|
||||
- 更改关键词(将XXX改为app简称)
|
||||
|
||||
```
|
||||
keywords="django XXXX verification security", # 关键词
|
||||
```
|
||||
|
||||
- 修改project_urls(将xxx改为app简称)
|
||||
|
||||
```
|
||||
project_urls={
|
||||
|
||||
"Bug Reports": "http://hzgit.hzsystems.cn/hertz_studio_django/hertz_studio_django_xxx/issues",
|
||||
|
||||
"Source": "http://hzgit.hzsystems.cn/hertz_studio_django/hertz_studio_django_xxx",
|
||||
|
||||
"Documentation": "http://hzgit.hzsystems.cn/hertz_studio_django/hertz_studio_django_xxx#readme",
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 六、打包
|
||||
|
||||
完成上述的修改后,在终端的项目输入以下命令并回车进行打包
|
||||
|
||||
```
|
||||
python setup.py sdist
|
||||
```
|
||||
|
||||
运行完成后会在dist目录下生成一个打包过后的文件
|
||||
Reference in New Issue
Block a user