235 lines
9.2 KiB
Python
235 lines
9.2 KiB
Python
# setup.py
|
|
import sys, os
|
|
from cx_Freeze import setup, Executable
|
|
from PySide6 import QtCore
|
|
import ssl
|
|
from setuptools import find_packages
|
|
from updateManager.__version__ import (
|
|
__title__, __version__, __description__, __author__,
|
|
__author_email__, __license__, __install_requires__,
|
|
__exe_name__, __icon_file__, __main_script__
|
|
)
|
|
import subprocess
|
|
from setuptools.command.build_ext import build_ext
|
|
from setuptools.command.install import install
|
|
from cx_Freeze.command.build_exe import build_exe as _build_exe
|
|
import importlib.util
|
|
|
|
# 패들 코어 패치 적용
|
|
print("패들 코어 패치 검사 및 적용...")
|
|
try:
|
|
import patch_paddle_core
|
|
patch_paddle_core.patch_paddle_core()
|
|
except Exception as e:
|
|
print(f"패들 코어 패치 적용 중 오류 발생: {e}")
|
|
print("패치 실패, 빌드 계속 진행합니다.")
|
|
|
|
# 필요한 파일 경로 설정
|
|
base_dir = os.path.dirname(__file__)
|
|
browsers_dir = os.path.join(base_dir, 'src', 'browsers')
|
|
chromium_dir = os.path.join(browsers_dir, 'src', 'browsers', 'chromium-1140')
|
|
whale_dir = os.path.join(browsers_dir, 'src', 'browsers', 'whale')
|
|
extensions_dir = os.path.join(browsers_dir, 'src', 'browsers', 'extensions')
|
|
user_data_dir = os.path.join(browsers_dir, 'src', 'browsers', 'user_data')
|
|
|
|
# include_files = [
|
|
# os.path.abspath('config.ini'),
|
|
# os.path.abspath('prompt.json'),
|
|
# os.path.abspath('userDB.db'),
|
|
# os.path.abspath('HakgyoansimDunggeunmisoTTFB.ttf'),
|
|
# (os.path.abspath('src/initialDB.db'), 'src/initialDB.db'),
|
|
# (os.path.abspath('src/Percenty_SS_Code.json'), 'src/Percenty_SS_Code.json'),
|
|
# (os.path.abspath(chromium_dir), 'browsers/chromium-1140'),
|
|
# (os.path.abspath(whale_dir), 'browsers/whale'),
|
|
# (os.path.abspath(extensions_dir), 'browsers/extensions'),
|
|
# (os.path.abspath(user_data_dir), 'browsers/user_data'),
|
|
# ]
|
|
|
|
# PySide6 DLL 경로 추가
|
|
# pyside6_path = os.path.join(os.path.dirname(sys.executable), "Lib", "site-packages", "PySide6")
|
|
# pyside6_plugins_path = os.path.join(pyside6_path, "plugins")
|
|
# pyside6_bin_path = pyside6_path # 'bin' 폴더가 없으면 기본 경로 사용
|
|
dll_files = [
|
|
# "LIBPQ.dll",
|
|
# "MIMAPI64.dll",
|
|
# "Qt63DQuickScene3D.dll",
|
|
"api-ms-win-core-com-l1-1-0.dll",
|
|
"api-ms-win-core-debug-l1-1-0.dll",
|
|
"api-ms-win-core-errorhandling-l1-1-0.dll",
|
|
"api-ms-win-core-handle-l1-1-0.dll",
|
|
"api-ms-win-core-heap-l1-1-0.dll",
|
|
# "api-ms-win-core-heap-l2-1-0.dll",
|
|
"api-ms-win-core-interlocked-l1-1-0.dll",
|
|
# "api-ms-win-core-libraryloader-l1-2-0.dll",
|
|
# "api-ms-win-core-libraryloader-l1-2-1.dll",
|
|
"api-ms-win-core-localization-l1-2-0.dll",
|
|
# "api-ms-win-core-path-l1-1-0.dll",
|
|
"api-ms-win-core-processthreads-l1-1-0.dll",
|
|
"api-ms-win-core-processthreads-l1-1-1.dll",
|
|
"api-ms-win-core-profile-l1-1-0.dll",
|
|
# "api-ms-win-core-realtime-l1-1-1.dll",
|
|
"api-ms-win-core-rtlsupport-l1-1-0.dll",
|
|
"api-ms-win-core-synch-l1-1-0.dll",
|
|
"api-ms-win-core-synch-l1-2-0.dll",
|
|
"api-ms-win-core-sysinfo-l1-1-0.dll",
|
|
# "api-ms-win-core-winrt-error-l1-1-0.dll",
|
|
# "api-ms-win-core-winrt-l1-1-0.dll",
|
|
# "api-ms-win-core-winrt-string-l1-1-0.dll",
|
|
"api-ms-win-crt-conio-l1-1-0.dll",
|
|
"api-ms-win-crt-environment-l1-1-0.dll",
|
|
"api-ms-win-crt-filesystem-l1-1-0.dll",
|
|
"api-ms-win-crt-multibyte-l1-1-0.dll",
|
|
"api-ms-win-crt-private-l1-1-0.dll",
|
|
"api-ms-win-crt-process-l1-1-0.dll",
|
|
"api-ms-win-crt-time-l1-1-0.dll",
|
|
"api-ms-win-crt-utility-l1-1-0.dll",
|
|
# "api-ms-win-power-base-l1-1-0.dll",
|
|
# "api-ms-win-power-setting-l1-1-0.dll",
|
|
# "api-ms-win-shcore-scaling-l1-1-1.dll",
|
|
]
|
|
|
|
# ✅ DLL 경로 설정 (Windows 10의 System32에서 가져오기)
|
|
system32_path = "C:/Windows/System32/downlevel"
|
|
dll_include_files = [(os.path.join(system32_path, dll), dll) for dll in dll_files]
|
|
|
|
# 패들 라이브러리 경로 설정
|
|
# 경로 수정: scripts/Lib -> Lib로 변경
|
|
base_path = os.path.dirname(os.path.abspath(__file__))
|
|
site_packages = os.path.join(base_path, "Lib", "site-packages")
|
|
|
|
# 올바른 경로 지정
|
|
paddle_path = os.path.join(site_packages, "paddle")
|
|
paddleocr_path = os.path.join(site_packages, "paddleocr")
|
|
|
|
paddle_includes = []
|
|
|
|
# 경로가 존재하는 경우에만 포함
|
|
if os.path.exists(paddle_path):
|
|
paddle_includes.append((paddle_path, 'lib/paddle'))
|
|
print(f"paddle 경로 추가: {paddle_path}")
|
|
|
|
if os.path.exists(paddleocr_path):
|
|
paddle_includes.append((paddleocr_path, 'lib/paddleocr'))
|
|
print(f"paddleocr 경로 추가: {paddleocr_path}")
|
|
|
|
# ✅ 기존 포함 파일 + DLL 추가
|
|
include_files = dll_include_files + paddle_includes + [
|
|
|
|
# 나머지 파일들
|
|
('src/ppocr/PP_Models', 'lib/src/ppocr/PP_Models'),
|
|
('AutoPercenty3.ico', 'AutoPercenty3.ico'),
|
|
('win.exe.manifest', 'win.exe.manifest'),
|
|
('libssl-3-x64.dll', 'libssl-3-x64.dll'),
|
|
('libcrypto-3-x64.dll', 'libcrypto-3-x64.dll'),
|
|
('kiprisCategories.json', 'kiprisCategories.json'),
|
|
('src/keyword/kiprisCategories.json', 'lib/src/keyword/kiprisCategories.json'),
|
|
('HakgyoansimDunggeunmisoTTFB.ttf', 'HakgyoansimDunggeunmisoTTFB.ttf'),
|
|
('퍼센티 다양한 카테고리 엑셀 수집(스스 기준).xlsx', '퍼센티 다양한 카테고리 엑셀 수집(스스 기준).xlsx'),
|
|
('src/Percenty_SS_Code.json', 'lib/src/Percenty_SS_Code.json'),
|
|
('src/browsers/chromium-1140', 'lib/src/browsers/chromium-1140'),
|
|
('src/browsers/whale', 'lib/src/browsers/whale'),
|
|
('src/browsers/extensions', 'lib/src/browsers/extensions'),
|
|
('src/browsers/user_data', 'lib/src/browsers/user_data'),
|
|
('src/browsers/whale/user_data', 'lib/src/browsers/whale/user_data'),
|
|
# (pyside6_bin_path, "PySide6"), # PySide6 DLL 파일 경로
|
|
# (pyside6_plugins_path, "PySide6/plugins"), # plugins 경로 추가
|
|
]
|
|
for src, dest in include_files:
|
|
if not os.path.exists(src):
|
|
print(f"경로가 존재하지 않습니다: {src}")
|
|
|
|
# 사용된 패키지 정의
|
|
build_exe_options = {
|
|
'packages': [
|
|
'ctypes', 'asyncio', 'os', 're', 'time', 'math', 'json', 'logging', 'shutil', 'random', 'base64',
|
|
'subprocess', 'configparser', 'pyperclip', 'numpy', 'numpy._core', 'numpy._core.tests',
|
|
'numpy.testing', 'numpy.core',
|
|
'cv2', 'requests', 'win32clipboard', 'win32gui',
|
|
'win32con', 'win32process', 'PIL', 'bs4', 'PySide6', 'psutil',
|
|
'collections', 'pandas', 'supabase', 'translatepy', 'comtypes', 'markdown', 'markdown.extensions',
|
|
'paddle', 'paddleocr', # paddle 관련 모듈 포함
|
|
'site'
|
|
],
|
|
'includes': [
|
|
'PySide6.QtWidgets', 'PySide6.QtCore', 'PySide6.QtGui', 'shiboken6',
|
|
'whale_translator', 'gui', 'logger_module', 'toggleSwitch',
|
|
'browser_control', 'clipboardImageManager', 'option',
|
|
'price', 'title', 'locatorManager', 'src.cmdDiag', 'src.inputDiag', 'src.keyword',
|
|
'src.priceSetDiag', 'comtypes.stream', 'markdown.extensions.extra', 'markdown.extensions.smarty', 'markdown.extensions.fenced_code', 'markdown.extensions.codehilite'
|
|
],
|
|
'include_files': include_files,
|
|
'excludes': [
|
|
'tkinter', 'PyQt4', 'PyQt5', 'AppKit', 'Foundation', 'IPython',
|
|
'OpenSSL', 'curses', 'test', 'matplotlib', 'asyncpg'
|
|
],
|
|
'zip_include_packages': [], # 아무 패키지도 압축하지 않음 (numpy 관련 문제 해결)
|
|
'silent': True # 디버그 메시지 활성화
|
|
}
|
|
|
|
# 애플리케이션 메인 파일 및 설정
|
|
base = None
|
|
if sys.platform == 'win32':
|
|
base = 'Win32GUI'
|
|
|
|
# ✅ 아이콘 지정: icon='파일경로.ico'
|
|
executables = [
|
|
Executable(
|
|
'main.py',
|
|
base=base,
|
|
target_name='AutoPercenty3.exe',
|
|
icon='AutoPercenty3.ico'
|
|
)
|
|
]
|
|
|
|
# PyInstaller 설정
|
|
if len(sys.argv) > 1 and sys.argv[1] == 'build_exe':
|
|
import PyInstaller.__main__
|
|
|
|
PyInstaller.__main__.run([
|
|
__main_script__,
|
|
'--name=%s' % __exe_name__,
|
|
'--onefile',
|
|
'--windowed',
|
|
'--icon=%s' % __icon_file__,
|
|
'--add-data=resources;resources'
|
|
])
|
|
|
|
# build_exe 클래스를 확장하여 빌드 후 iss 파일 생성
|
|
class build_exe(_build_exe):
|
|
def run(self):
|
|
# 원래 빌드 프로세스 실행
|
|
_build_exe.run(self)
|
|
|
|
print("\n빌드가 완료되었습니다. 이제 Inno Setup 스크립트 생성을 시작합니다...\n")
|
|
|
|
try:
|
|
# generate_iss.py 스크립트 실행
|
|
result = subprocess.run([sys.executable, "generate_iss.py"], capture_output=True, text=True)
|
|
if result.returncode == 0:
|
|
print(result.stdout)
|
|
print("\nInno Setup 스크립트 생성이 완료되었습니다!")
|
|
else:
|
|
print(f"Inno Setup 스크립트 생성 중 오류 발생: {result.stderr}")
|
|
except Exception as e:
|
|
print(f"Inno Setup 스크립트 생성 중 예외 발생: {e}")
|
|
|
|
# Setup 설정 (cmdclass에 build_exe 추가)
|
|
setup(
|
|
name=__title__,
|
|
version=__version__,
|
|
description=__description__,
|
|
author=__author__,
|
|
author_email=__author_email__,
|
|
license=__license__,
|
|
packages=find_packages(),
|
|
install_requires=__install_requires__,
|
|
python_requires='>=3.11',
|
|
include_package_data=True,
|
|
zip_safe=False,
|
|
options={'build_exe': build_exe_options},
|
|
executables=executables,
|
|
cmdclass={
|
|
"build_exe": build_exe,
|
|
},
|
|
)
|