Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to pyinstaller from cx_freeze #565

Merged
merged 2 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ cocoa/autogen
/help/*/changelog.rst

*.pyd
*.exe
*.exe
*.spec
72 changes: 23 additions & 49 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,64 +114,38 @@ def package_source_tgz():
print_and_do('gzip {}'.format(dest))

def package_windows():
from cx_Freeze import setup, Executable
app_version = get_module_version('core')
arch = platform.architecture()[0]
buildpath = op.join('build', 'dupeguru-win{}'.format(arch))
# remove existing build directory
if op.exists(buildpath):
shutil.rmtree(buildpath)
include_files = []
# Information to pass to pyinstaller and NSIS
version_array = app_version.split('.')
match = re.search('[0-9]+', arch)
bits = match.group(0)
# include locale files if they are built otherwise exit as it will break
# the localization
if op.exists('build/locale'):
include_files.append(('build/locale', 'locale'))
else:
if not op.exists('build/locale'):
print("Locale files not built, exiting...")
return
# include help files if they are built otherwise exit as they should be included?
if op.exists('build/help'):
include_files.append(('build/help', 'help'))
else:
if not op.exists('build/help'):
print("Help files not built, exiting...")
return
# options for cx_Freeze
# if zip_include packages is not used, the cx_Freeze packager will include
# the whole PyQT5 directory
options = {
'build_exe': {
'build_exe': buildpath,
'excludes': [],
'includes': ['atexit', 'dbm.dumb'],
'include_files': include_files,
'include_msvcr': True,
'zip_include_packages': ['*'],
'zip_exclude_packages': []
},
}
# executables to build, uses se edition icon
executables = [
Executable(
script='run.py',
base='Win32GUI',
targetName='dupeguru.exe',
icon='images/dgse_logo.ico',
copyright='Copyright (C) 2017 Hardcoded Software'
)
]
# call cx_freeze
setup(
name='dupeguru',
version=app_version,
description='Tool to find duplicate files on your computer.',
options=options,
executables=executables,
script_args=['build']
)
# Information to pass to NSIS
version_array = app_version.split('.')
match = re.search('[0-9]+', arch)
bits = match.group(0)
# create version information file from template
try:
version_template = open("win_version_info.temp", "r")
version_info = version_template.read()
version_template.close()
version_info_file = open("win_version_info.txt", "w")
version_info_file.write(version_info.format(version_array[0], version_array[1], version_array[2], bits))
version_info_file.close()
except Exception:
print("Error creating version info file, exiting...")
return
# run pyinstaller via command line
print_and_do('pyinstaller -w --name=dupeguru-win{0} --icon=images/dgse_logo.ico '
'--add-data "build/locale;locale" --add-data "build/help;help" '
'--version-file win_version_info.txt run.py'.format(bits))
# remove version info file
os.remove('win_version_info.txt')
# Call NSIS (TODO update to not use hardcoded path)
cmd = ('"C:\\Program Files (x86)\\NSIS\\Bin\\makensis.exe" '
'/DVERSIONMAJOR={0} /DVERSIONMINOR={1} /DVERSIONPATCH={2} /DBITS={3} setup.nsi')
Expand Down
4 changes: 2 additions & 2 deletions requirements-windows.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PyQt5 >=5.4,<6.0
cx-Freeze>=5.1.1
pypiwin32>=200
pypiwin32>=200
pyinstaller>=3.4,<4.0
21 changes: 11 additions & 10 deletions setup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SetCompressor /SOLID lzma
!endif
!ifndef SOURCEPATH
!echo "SOURCEPATH is NOT defined"
!define SOURCEPATH "build"
!define SOURCEPATH "dist"
!endif
!ifndef VERSIONMAJOR | VERSIONMINOR | VERSIONPATCH | BITS | SOURCEPATH
!error "Command line Defines missing use /DDEFINE=VALUE to define before script"
Expand Down Expand Up @@ -161,12 +161,12 @@ Section "!Application" AppSec
SetOutPath "$INSTDIR" ; set from result of installer pages

; Files to install
File /r "${SOURCEPATH}\${APPNAME}-win${BITS}bit\*"
File /r "${SOURCEPATH}\${APPNAME}-win${BITS}\*"

; Create Start Menu Items
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\${APPNAME}.lnk" "$INSTDIR\${APPNAME}.exe"
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\${APPNAME}.lnk" "$INSTDIR\${APPNAME}-win${BITS}.exe"
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
!insertmacro MUI_STARTMENU_WRITE_END

Expand Down Expand Up @@ -223,15 +223,16 @@ Section "Uninstall"
RMDir /r "$SMPROGRAMS\$StartMenuFolder"

; Remove Files & Folders in Install Folder
RMDir /r "$INSTDIR\core"
RMDir /r "$INSTDIR\help"
RMDir /r "$INSTDIR\imageformats"
RMDir /r "$INSTDIR\lib"
RMDir /r "$INSTDIR\PyQt5"
RMDir /r "$INSTDIR\qt"
RMDir /r "$INSTDIR\locale"
RMDir /r "$INSTDIR\platforms"
Delete "$INSTDIR\dupeguru.exe"
Delete "$INSTDIR\python36.dll"
Delete "$INSTDIR\sqlite3.dll"
Delete "$INSTDIR\Uninstall.exe"
Delete "$INSTDIR\*.exe"
Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\*.pyd"
Delete "$INSTDIR\*.zip"
Delete "$INSTDIR\*.manifest"

; Remove Install Folder if empty
RMDir "$INSTDIR"
Expand Down
43 changes: 43 additions & 0 deletions win_version_info.temp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
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=({0}, {1}, {2}, 0),
prodvers=({0}, {1}, {2}, 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=0x40004,
# 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'Hardcoded Software'),
StringStruct(u'FileDescription', u'dupeGuru is a tool to find duplicate files on your computer.'),
StringStruct(u'FileVersion', u'{0}.{1}.{2}.0'),
StringStruct(u'InternalName', u'dupeGuru'),
StringStruct(u'LegalCopyright', u'© Hardcoded Software'),
StringStruct(u'OriginalFilename', u'dupeguru-win{3}.exe'),
StringStruct(u'ProductName', u'dupeGuru'),
StringStruct(u'ProductVersion', u'{0}.{1}.{2}.0')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)