update cx_freeze example and add a workaround for templates

This commit is contained in:
Fernando Bordignon 2021-05-24 17:50:24 -03:00
parent ed1653f3c5
commit a4de137535
2 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import sys import sys
from PyQt4 import QtGui from pyqtgraph.Qt import QtGui
import pyqtgraph as pg import pyqtgraph as pg
from pyqtgraph.graphicsItems import TextItem from pyqtgraph.graphicsItems import TextItem
# For packages that require scipy, these may be needed: # For packages that require scipy, these may be needed:

View File

@ -1,5 +1,6 @@
# Build with `python setup.py build_exe` # Build with `python setup.py build_exe`
from cx_Freeze import setup, Executable from cx_Freeze import setup, Executable
from pathlib import Path
import shutil import shutil
from glob import glob from glob import glob
@ -8,12 +9,24 @@ shutil.rmtree("build", ignore_errors=True)
shutil.rmtree("dist", ignore_errors=True) shutil.rmtree("dist", ignore_errors=True)
import sys import sys
includes = ['PyQt4.QtCore', 'PyQt4.QtGui', 'sip', 'pyqtgraph.graphicsItems', includes = ['pyqtgraph.graphicsItems',
'numpy', 'atexit'] 'numpy', 'atexit']
excludes = ['cvxopt','_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger', excludes = ['cvxopt','_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl','tables', 'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl','tables',
'Tkconstants', 'Tkinter', 'zmq','PySide','pysideuic','scipy','matplotlib'] 'Tkconstants', 'Tkinter', 'zmq','PySide','pysideuic','scipy','matplotlib']
# Workaround for making sure the templates are included in the frozen app package
include_files = []
import pyqtgraph
pg_folder = Path(pyqtgraph.__file__).parent
templates = pg_folder.rglob('*template*.py')
sources = [str(w) for w in templates]
destinations = ['lib' + w.replace(str(pg_folder.parent), '') for w in sources]
for a in zip(sources, destinations):
include_files.append(a)
print(include_files)
if sys.version[0] == '2': if sys.version[0] == '2':
# causes syntax error on py2 # causes syntax error on py2
excludes.append('PyQt4.uic.port_v3') excludes.append('PyQt4.uic.port_v3')
@ -24,11 +37,10 @@ if sys.platform == "win32":
build_exe_options = {'excludes': excludes, build_exe_options = {'excludes': excludes,
'includes':includes, 'include_msvcr':True, 'includes':includes, 'include_msvcr':True,
'compressed':True, 'copy_dependent_files':True, 'create_shared_zip':True, 'optimize':1, "include_files": include_files,}
'include_in_shared_zip':True, 'optimize':2}
setup(name = "cx_freeze plot test", setup(name = "cx_freeze plot test",
version = "0.1", version = "0.2",
description = "cx_freeze plot test", description = "cx_freeze plot test",
options = {"build_exe": build_exe_options}, options = {"build_exe": build_exe_options},
executables = [Executable("plotTest.py", base=base)]) executables = [Executable("plotTest.py", base=base)])