Merge pull request #1802 from fbordignon/cx_freeze_example

update cx_freeze example and add a workaround for templates
This commit is contained in:
Ogi Moore 2021-05-24 14:13:07 -07:00 committed by GitHub
commit 7bc5f215c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

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

View File

@ -1,5 +1,6 @@
# Build with `python setup.py build_exe`
from cx_Freeze import setup, Executable
from pathlib import Path
import shutil
from glob import glob
@ -8,12 +9,24 @@ shutil.rmtree("build", ignore_errors=True)
shutil.rmtree("dist", ignore_errors=True)
import sys
includes = ['PyQt4.QtCore', 'PyQt4.QtGui', 'sip', 'pyqtgraph.graphicsItems',
includes = ['pyqtgraph.graphicsItems',
'numpy', 'atexit']
excludes = ['cvxopt','_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl','tables',
'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':
# causes syntax error on py2
excludes.append('PyQt4.uic.port_v3')
@ -24,11 +37,10 @@ if sys.platform == "win32":
build_exe_options = {'excludes': excludes,
'includes':includes, 'include_msvcr':True,
'compressed':True, 'copy_dependent_files':True, 'create_shared_zip':True,
'include_in_shared_zip':True, 'optimize':2}
'optimize':1, "include_files": include_files,}
setup(name = "cx_freeze plot test",
version = "0.1",
version = "0.2",
description = "cx_freeze plot test",
options = {"build_exe": build_exe_options},
executables = [Executable("plotTest.py", base=base)])