컴퓨터2012. 1. 18. 01:07
시간이 없는 관계로 길게는 포스팅을 못하겠지만..  지난 삽질을 생각하면 눈물이 앞을 가린다.. ㅠ_ㅠ 

우선 포스팅을 해주신 이분
http://cshong.tistory.com/entry/py2exe-인스톨-팩토리-install-factory-사용법

이분에게 깊은 경외와 감사를 보내며..
긴삽질을 마치려고 한다. (물런 테스트 해봐야 아는거지만;; ) 

python 코드를 exe파일로 만드는 법은 우선 py2exe란 패키지가 필요하다. 
그다음에 만드는 법은 웬만한 웹사이트에 잘 알려져 있다.
하지만 나처럼 배포판으로 하나의 실행파일로 만들고 싶은 경우 이야기가 조금 다르다.

위의 링크의 방법대로

from distutils.core import setup
import py2exe

excludes = [
    "pywin",
    "pywin.debugger",
    "pywin.debugger.dbgcon",
    "pywin.dialogs",
    "pywin.dialogs.list",
    "win32com.server",
]

options = {
    "bundle_files": 1,                 # create singlefile exe
    "compressed"  : 1,                 # compress the library archive
    "excludes"    : excludes,
    "dll_excludes": ["w9xpopen.exe"]   # we don't need this
}

setup(
    options = {"py2exe": options},
    zipfile = None,                    # append zip-archive to the executable
    console = ["sample.py"]
)

이것을 넣고 돌려주면 무리 없이 완성된다..

ps. 그외에 한동안 삽질을 한게 있었는데 기존 소스코드에서 import한 파일이 include가 안되는 경우다.
이 경우에는 패키지 파일을 직접 python의 디렉토리에 넣어놓으면 자연스럽게 해결된다.
(???.egg파일을 압축을 풀어서 디렉토리에 넣으면 끝. ) 
 

자.. 이제 테스트 결과를 기다려 볼까..

 
Posted by blindfish