-
Notifications
You must be signed in to change notification settings - Fork 35
How to compile to binary
juliencegarra edited this page Jan 22, 2020
·
4 revisions
In order to easily create Executable version of OpenMATB from source. Use the following helper (batch file) and the following python script. They will create a Zip file containing the current version. This zip file contains all necessary file to deploy OpenMATB on Windows systems. Cx-freeze package is necessary for a successful compilation
@RD /S /q OpenMATB
python.exe compilation_cxfreeze.py build
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, os, zipfile
# get version number
_version = "unknown version"
for lineBuf in open('OpenMATB.py', 'r'):
s = lineBuf.replace(' ','').upper()
pos = s.find('VERSION="')
if pos>-1:
_version = s[9:len(s)-2]
break
def includedirectory(rootdir, extension):
for subdir, dirs, files in os.walk(rootdir):
for file in files:
filepath = os.path.join(subdir, file)
if filepath.endswith(extension):
include_files.extend([(filepath, filepath)])
#############################################################################
include_files = ['config.txt', 'inpout32.dll']
includes = ['PySide2', 'pygame', 'wave', 'numpy', 'numpy.core._methods', 'numpy.lib.format', 'email']
excludes = ['tcl', 'Tkconstants', 'Tkinter']
packages = []
path = []
includedirectory('Helpers', '.py')
includedirectory('Instructions', '.txt')
includedirectory('Plugins', '.py')
includedirectory('Scales', '.txt')
includedirectory('Scenarios', '.txt')
includedirectory('Sounds', '.wav')
includedirectory('Translations', '.txt')
from cx_Freeze import setup, Executable
GUI2Exe_Target_1 = Executable(
# what to build
script = "OpenMATB.py",
initScript = None,
base = 'Win32GUI', # Hide the console
targetName = "OpenMATB.exe"
)
setup(
name = "OpenMATB",
version = _version,
description = "OpenMATB",
author = "Julien Cegarra & Benoit Valery",
options = {"build_exe": {"includes": includes,
"include_files": include_files,
"excludes": excludes,
"packages": packages,
"path": path,
"build_exe" : "OpenMATB"
#"create_shared_zip": False,
}
},
executables = [GUI2Exe_Target_1]
)
# CREATE A ZIP FILE
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
zipf = zipfile.ZipFile('OpenMATB_v'+_version+'.zip', 'w', zipfile.ZIP_DEFLATED)
zipdir('OpenMATB/', zipf)
zipf.close()