forked from RapidAI/RapidOCR
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AutumnSun1996
committed
Aug 21, 2022
1 parent
36c5080
commit a4f9cf1
Showing
6 changed files
with
142 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import os | ||
import shutil | ||
|
||
print('Compile ocrweb') | ||
os.system('pyinstaller -y main.spec') | ||
|
||
print('Compile wrapper') | ||
os.system('windres .\wrapper.rc -O coff -o wrapper.res') | ||
os.system('gcc .\wrapper.c wrapper.res -o dist/ocrweb.exe') | ||
|
||
print('Copy config.yaml') | ||
shutil.copy2('config.yaml', 'dist/config.yaml') | ||
|
||
print('Copy models') | ||
shutil.copytree('models', 'dist/models', dirs_exist_ok=True) | ||
os.remove('dist/models/.gitkeep') | ||
|
||
print('Pack to ocrweb.zip') | ||
shutil.make_archive('ocrweb', 'zip', 'dist') | ||
|
||
print('Done') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- mode: python ; coding: utf-8 -*- | ||
|
||
|
||
block_cipher = None | ||
|
||
|
||
a = Analysis( | ||
['main.py'], | ||
pathex=[], | ||
binaries=[], | ||
datas=[ | ||
('static', 'static'), | ||
], | ||
hiddenimports=[], | ||
hookspath=[], | ||
hooksconfig={}, | ||
runtime_hooks=[], | ||
excludes=[], | ||
win_no_prefer_redirects=False, | ||
win_private_assemblies=False, | ||
cipher=block_cipher, | ||
noarchive=False, | ||
) | ||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) | ||
|
||
exe = EXE( | ||
pyz, | ||
a.scripts, | ||
[], | ||
exclude_binaries=True, | ||
name='main', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
console=True, | ||
disable_windowed_traceback=False, | ||
argv_emulation=False, | ||
target_arch=None, | ||
codesign_identity=None, | ||
entitlements_file=None, | ||
) | ||
coll = COLLECT( | ||
exe, | ||
a.binaries, | ||
a.zipfiles, | ||
a.datas, | ||
strip=False, | ||
upx=True, | ||
upx_exclude=[], | ||
name='ocrweb', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
针对Pyinstaller目录下文件过多的问题, 使用外部exe+system调用的方式实现资源文件/依赖库分离 | ||
*/ | ||
#include <windows.h> | ||
#include <stdio.h> | ||
|
||
void combine(char *destination, const char *path1, const char *path2) | ||
{ | ||
if (path1 == NULL && path2 == NULL) | ||
{ | ||
strcpy(destination, ""); | ||
} | ||
else if (path2 == NULL || strlen(path2) == 0) | ||
{ | ||
strcpy(destination, path1); | ||
} | ||
else if (path1 == NULL || strlen(path1) == 0) | ||
{ | ||
strcpy(destination, path2); | ||
} | ||
else | ||
{ | ||
strcpy(destination, path1); | ||
|
||
size_t idx = 0, sepIdx = 0; | ||
size_t size1 = strlen(path1); | ||
while (idx < size1) | ||
{ | ||
idx++; | ||
if (destination[idx] == '\\' || destination[idx] == '/') | ||
{ | ||
sepIdx = idx; | ||
} | ||
} | ||
// Trim destination: delete from last separator to end. | ||
destination[sepIdx + 1] = '\0'; | ||
strcat(destination, path2); | ||
} | ||
} | ||
|
||
void main() | ||
{ | ||
// Set title | ||
system("title Rapid OCR Server"); | ||
// Get wrapper exe path | ||
TCHAR path[MAX_PATH]; | ||
GetModuleFileName(NULL, path, MAX_PATH); | ||
|
||
TCHAR exe_path[MAX_PATH]; | ||
// Get real exe path from wrapper exe path | ||
combine(exe_path, path, "ocrweb\\main.exe"); | ||
printf("Run real exe: %s\n", exe_path); | ||
// Run real exe | ||
system(exe_path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
id ICON "static/favicon.ico" |