opencc need in pyinstaller --add-data

This commit is contained in:
lededev
2021-11-01 05:07:53 +08:00
parent 3b498d32ca
commit 3786f58bb6
6 changed files with 15 additions and 3 deletions

View File

@@ -42,6 +42,7 @@ jobs:
--hidden-import ADC_function.py \
--hidden-import core.py \
--add-data "$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1):cloudscraper" \
--add-data "$(python -c 'import opencc as _; print(_.__path__[0])' | tail -n 1):opencc" \
--add-data "Img:Img" \
--add-data "config.ini:." \
@@ -53,6 +54,7 @@ jobs:
--hidden-import ADC_function.py `
--hidden-import core.py `
--add-data "$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1);cloudscraper" `
--add-data "$(python -c 'import opencc as _; print(_.__path__[0])' | tail -n 1);opencc" `
--add-data "Img;Img" `
--add-data "config.ini;." `

View File

@@ -7,7 +7,7 @@ import shutil
import typing
import urllib3
import signal
import opencc
from opencc import OpenCC
import config
from datetime import datetime, timedelta
@@ -400,7 +400,7 @@ def create_data_and_move(file_path: str, zero_op, oCC):
if zero_op:
return
if n_number:
core_main(file_path, n_number)
core_main(file_path, n_number, oCC)
else:
raise ValueError("number empty")
print("[*]======================================================")
@@ -491,7 +491,12 @@ def main():
# create OpenCC converter
ccm = conf.cc_convert_mode()
oCC = None if ccm == 0 else opencc.OpenCC('t2s.json' if ccm == 1 else 's2t.json')
try:
oCC = None if ccm == 0 else OpenCC('t2s.json' if ccm == 1 else 's2t.json')
except:
# some OS no OpennCC cpython, try opencc-python-reimplemented.
# pip uninstall opencc && pip install opencc-python-reimplemented
oCC = None if ccm == 0 else OpenCC('t2s' if ccm == 1 else 's2t')
if not single_file_path == '': #Single File
print('[+]==================== Single File =====================')

View File

@@ -17,6 +17,7 @@ make:
@echo "[+]Pyinstaller make"
pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py \
--add-data "`python3 -c 'import opencc as _; print(_.__path__[0])' | tail -n 1`:opencc" \
--add-data "Img:Img" \
--add-data "config.ini:." \

View File

@@ -2,6 +2,7 @@
# Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
$CLOUDSCRAPER_PATH=$(python -c 'import cloudscraper as _; print(_.__path__[0])' | select -Last 1)
$OPENCC_PATH=$(python -c 'import opencc as _; print(_.__path__[0])' | select -Last 1)
mkdir build
mkdir __pycache__
@@ -10,6 +11,7 @@ pyinstaller --onefile AV_Data_Capture.py `
--hidden-import ADC_function.py `
--hidden-import core.py `
--add-data "$CLOUDSCRAPER_PATH;cloudscraper" `
--add-data "$OPENCC_PATH;opencc" `
--add-data "Img;Img" `
--add-data "config.ini;." `

View File

@@ -2,6 +2,7 @@ pkg install python38 py38-requests py38-pip py38-lxml py38-pillow py38-cloudscra
pip install pyquery pyinstaller
pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py \
--add-data "$(python3.8 -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1):cloudscraper" \
--add-data "$(python3.8 -c 'import opencc as _; print(_.__path__[0])' | tail -n 1):opencc" \
--add-data "Img:Img" \
--add-data "config.ini:." \

View File

@@ -14,6 +14,7 @@ pip3 install -r requirements.txt
pip3 install cloudscraper==1.2.52
pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py \
--add-data "$(python3 -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1):cloudscraper" \
--add-data "$(python3 -c 'import opencc as _; print(_.__path__[0])' | tail -n 1):opencc" \
--add-data "Img:Img" \
--add-data "config.ini:." \