TaoSourcerer/cfg_update.py

29 lines
1.0 KiB
Python

import os
import logging
# 로거 인스턴스 가져오기
logger = logging.getLogger('default_logger')
# 환경 변수에서 정보 가져오기
python_home = os.environ.get('MY_PYTHON_HOME')
python_executable = os.environ.get('MY_PYTHON_EXECUTABLE')
pyvenv_cfg_path = os.path.join(python_home, '..', 'pyvenv.cfg')
# pyvenv.cfg 파일 수정
with open(pyvenv_cfg_path, 'r') as file:
cfg_content = file.readlines()
with open(pyvenv_cfg_path, 'w') as file:
for line in cfg_content:
if line.startswith('home ='):
file.write(f'home = {python_home}\n')
elif line.startswith('executable ='):
file.write(f'executable = {python_executable}\n')
else:
file.write(line)
# Qt 플러그인 경로 설정
qt_plugin_path = os.path.join(python_home, '../Lib/site-packages/PyQt5/Qt5/plugins', 'QtPlugins') # 예제 경로, 실제 경로로 조정 필요
os.environ['QT_PLUGIN_PATH'] = qt_plugin_path
logger.debug("pyvenv.cfg 파일이 업데이트 되었습니다.")