From 0fb5f05fad5ee748200e036c1d7a707de7092405 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Thu, 3 Apr 2014 13:31:02 -0400 Subject: [PATCH 1/2] Added py2exe example from Nitish --- examples/py2exe/plotTest.py | 20 ++++++++++++++++++++ examples/py2exe/setup.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 examples/py2exe/plotTest.py create mode 100644 examples/py2exe/setup.py diff --git a/examples/py2exe/plotTest.py b/examples/py2exe/plotTest.py new file mode 100644 index 00000000..1a53a984 --- /dev/null +++ b/examples/py2exe/plotTest.py @@ -0,0 +1,20 @@ +import sys +from PyQt4 import QtGui +import pyqtgraph as pg +from pyqtgraph.graphicsItems import TextItem +# For packages that require scipy, these may be needed: +# from scipy.stats import futil +# from scipy.sparse.csgraph import _validation + +from pyqtgraph import setConfigOption +pg.setConfigOption('background','w') +pg.setConfigOption('foreground','k') +app = QtGui.QApplication(sys.argv) + +pw = pg.plot(x = [0, 1, 2, 4], y = [4, 5, 9, 6]) +pw.showGrid(x=True,y=True) +text = pg.TextItem(html='
%s
' % "here",anchor=(0.0, 0.0)) +text.setPos(1.0, 5.0) +pw.addItem(text) +status = app.exec_() +sys.exit(status) diff --git a/examples/py2exe/setup.py b/examples/py2exe/setup.py new file mode 100644 index 00000000..760ed6a4 --- /dev/null +++ b/examples/py2exe/setup.py @@ -0,0 +1,32 @@ +from distutils.core import setup + +import shutil +from glob import glob +# Remove the build folder +shutil.rmtree("build", ignore_errors=True) +shutil.rmtree("dist", ignore_errors=True) +import py2exe +import sys + +includes = ['PyQt4', 'PyQt4.QtGui', 'PyQt4.QtSvg', 'sip', 'pyqtgraph.graphicsItems'] +excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger', + 'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl', + 'Tkconstants', 'Tkinter', 'zmq'] +packages = [] +dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll', + 'tk84.dll', 'MSVCP90.dll'] +icon_resources = [] +bitmap_resources = [] +other_resources = [] +data_files = [] +setup( + data_files=data_files, + console=['plotTest.py'] , + options={"py2exe": {"excludes": excludes, + "includes": includes, + "dll_excludes": dll_excludes, + "optimize": 2, + "compressed": 2, + "bundle_files": 1}}, + zipfile=None, +) From cae310c570faf6c54325ad88b7d03c1085fff842 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Thu, 3 Apr 2014 13:33:16 -0400 Subject: [PATCH 2/2] Fix: avoid importing py3 module from pyqt when using py2 --- examples/py2exe/setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/py2exe/setup.py b/examples/py2exe/setup.py index 760ed6a4..c342f90d 100644 --- a/examples/py2exe/setup.py +++ b/examples/py2exe/setup.py @@ -12,6 +12,10 @@ includes = ['PyQt4', 'PyQt4.QtGui', 'PyQt4.QtSvg', 'sip', 'pyqtgraph.graphicsIte excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger', 'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl', 'Tkconstants', 'Tkinter', 'zmq'] +if sys.version[0] == '2': + # causes syntax error on py2 + excludes.append('PyQt4.uic.port_v3') + packages = [] dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll', 'tk84.dll', 'MSVCP90.dll'] @@ -25,7 +29,7 @@ setup( options={"py2exe": {"excludes": excludes, "includes": includes, "dll_excludes": dll_excludes, - "optimize": 2, + "optimize": 0, "compressed": 2, "bundle_files": 1}}, zipfile=None,