32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import shutil
|
|
import os
|
|
import subprocess
|
|
|
|
# 가상 환경 경로 (필요에 따라 변경)
|
|
venv_path = os.path.join(os.getcwd(), 'venv')
|
|
|
|
# 삭제할 디렉토리 목록
|
|
folders_to_delete = ['build', 'dist']
|
|
|
|
# 현재 디렉토리 내의 폴더들을 순회하며 삭제
|
|
for folder in folders_to_delete:
|
|
if os.path.exists(folder):
|
|
shutil.rmtree(folder)
|
|
print(f"{folder} 폴더를 삭제했습니다.")
|
|
|
|
# 가상 환경 활성화 및 cx_Freeze 빌드 실행
|
|
try:
|
|
if os.name == 'nt': # Windows
|
|
activate_script = os.path.join(venv_path, 'Scripts', 'activate.bat')
|
|
# cmd 명령어를 통해 가상 환경 활성화 후 setup.py 빌드 실행
|
|
command = f'cmd /c "{activate_script} && python setup.py build"'
|
|
result = subprocess.run(command, shell=True, check=True)
|
|
print(result)
|
|
else: # Linux/Mac
|
|
activate_script = os.path.join(venv_path, 'bin', 'activate')
|
|
command = f'/bin/bash -c "source {activate_script} && python setup.py build"'
|
|
subprocess.run(command, shell=True, check=True)
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"Error: {e}")
|
|
|