Converting the editor to an executable file to use on Linux 64
Closed this issue · 2 comments
zeyadhany98 commented
I'm facing an issue in converting the editor to an exe file to use on linux
I'm using this command:
pyinstaller --onefile exco.py
could you please suggest a way to use ?
matkuki commented
Sure, here is a Linux Python freeze script, you will need to pip install cx_freeze
for it to work. Save the code below to a Python file and run it.
The script assumes that the ExCo
source is in a directory "ExCo-master" next to the script, and it will compile ExCo into "ExCo-Compiled" directory next to the script. You can adjust the directories as you need at the top of the main
function.
Hope it helps.
import os
import sys
import pprint
import shutil
import inspect
import platform
import cx_Freeze
def main():
file_directory = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
exco_directory = os.path.join(file_directory, "ExCo-master")
os.chdir(exco_directory)
output_directory = os.path.join(exco_directory, "ExCo-Compiled")
builtin_modules = [
"psutil",
]
local_modules = []
# List all local modules
exclude_dirs = [
'cython',
'nim',
'utilities',
'git_clone',
]
excluded_modules = [
'freeze_exco',
'git_clone',
]
for root, dirs, files in os.walk(exco_directory):
base_path = os.path.join(root).replace(exco_directory, "")
if base_path.startswith('/'):
base_path = base_path[1:]
if any([x in base_path for x in exclude_dirs]):
continue
for f in files:
if f.endswith('.py'):
raw_module = f.replace('.py', '') \
.replace('.pyd', '') \
.replace('.so', '')
raw_module = raw_module.split('.')[0]
new_module = f'{base_path}/{raw_module}'
if new_module.startswith('\\') or new_module.startswith('/'):
new_module = new_module[1:]
new_module = new_module.replace('\\', '.').replace('/', '.')
if new_module in excluded_modules:
continue
local_modules.append(new_module)
pprint.pprint(local_modules)
modules = local_modules + builtin_modules
search_path = sys.path
search_path.append(exco_directory)
executables = [
cx_Freeze.Executable(
'exco.py',
initScript = None,
base = None,
icon = "resources/exco-icon-win.ico",
targetName = 'ExCo',
)
]
freezer = cx_Freeze.Freezer(
executables,
includes = modules,
excludes = [
"tkinter",
],
replacePaths = [],
compress = True,
optimizeFlag = True,
path = search_path,
targetDir = output_directory,
includeFiles = [],
zipIncludes = [],
silent = False,
)
freezer.Freeze()
shutil.copytree("resources", output_directory + "/resources")
if __name__ == "__main__":
main()
zeyadhany98 commented
@matkuki , you are a lifesaver !!
it really worked fine
Really Great Editor Thank you!