Development/파이썬 [Python]

[Python] pyinstaller로 exe 실행파일 만들때 파일 버전정보 설정

요체크다 2020. 12. 30. 00:33
반응형

 파이썬에서 pyinstaller를 통해 exe 실행파일을 생성하는 경우 별도로 파일 버전을 설정하지 않아도 아무 문제없이 exe 실행파일 생성이 가능합니다.

 다만, 소스코드가 길어지고 코드 수정이 잦아지게 되면 결국 exe 실행파일을 여러번 만들게 되는데, 이런 경우 exe 실행파일 관리하는 부분에 있어 어려움이 발생하게 되어 exe 실행파일에 파일버전을 설정하여 좀더 수월한 관리가 가능합니다.

 추가적으로 exe 실행파일을 좀더 고급스럽고 전문가적인 느낌을 주기위해서도 exe 실행파일에 파일 버전 정보를 설정하는 것을 개인적으로는 추천해 드리고 싶습니다.

 

 pyinstaller를 통해 exe 실행파일 만들때 파일 버전정보를 설정하는 방법은 아래와 같이 프로젝트 경로에 아래의 샘플내역을 txt 파일형태로 저장한 다음 "--version-file" 옵션을 통해 txt 파일을 불러오시면 됩니다.


1. 준비사항

 1) txt 샘플내역 저장 및 편집

  - 아래 txt 샘플내역 저장 후 빨간색 글자 부분만 편집하여 프로젝트 경로에 파일을 위치 시켜 줍니다.

  - txt 샘플내역은 아래 첨부파일에서 다운 받으시면 됩니다.

file_version_info.txt
0.00MB

2) txt 샘플내역

# UTF-8

#

VSVersionInfo(
  ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)

# Set not needed items to zero 0.
filevers=(1, 0, 0, 0),
prodvers=(1, 0, 0, 0),

# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,

# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x4,
# The general type of file.

# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,

# Creation date and time stamp.
date=(0, 0)
),
  kids=[
StringFileInfo(

  [
  StringTable(
    u'040904B0',
    [StringStruct(u'CompanyName', u''),
    StringStruct(u'FileDescription', u'test'),
    StringStruct(u'FileVersion', u'1.0.0.0'),
    StringStruct(u'InternalName', u''),
    StringStruct(u'LegalCopyright', u''),
    StringStruct(u'OriginalFilename', u''),
    StringStruct(u'ProductName', u'test.exe'),
    StringStruct(u'ProductVersion', u'1.0.0.0')])
  ]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
  ]
)

2. 설정 옵션 및 명령어

 1) 옵션

  --version-file txt파일명

 

 2) 명령어

 #pyinstaller 파이썬소스.py --version-file file_version.txt

3) 파일 버전 확인

 - pyinstaller로 exe 실행파일을 생성하는 경우 프로젝트 경로의 'dist" 라고 하는 디렉토리에 생성됩니다.

 - exe 실행파일에서 마우스 우클릭 후 "속성" 메뉴에 들으간 다음 "자세히" 탭을 보면 위에서 설정한 파일 버전정보가 잘 설정된 것을 확인 할 수 있습니다.

 

반응형