Differences between revisions 1 and 2
Revision 1 as of 2004-05-19 18:09:52
Size: 1342
Editor: 206
Comment:
Revision 2 as of 2004-05-19 18:13:21
Size: 1730
Editor: 206
Comment:
Deletions are marked like this. Additions are marked like this.
Line 26: Line 26:
    # Additional data files required by matplotlib. Note that the glob.glob routine doesn't seem to pick up the .matplotlib resource file     # Additional data files required by matplotlib.
    # Note that the glob.glob routine doesn't seem to pick up
    # the .matplotlib resource file, so I copy that separately.
    data_files = [('matplotlib', glob.glob(r'c:\python23\share\matplotlib\*')),
                  ('matplotlib', [r'c:\python23\share\matplotlib\.matplotlibrc'])],

    # Name and description of the program to create
    name = 'demo'
    description = 'MatPlotLib Demo Program'

    # Targets to build
    console = ['demo.py']
    )

Introduction

Changes required to matplotlib

I had to patch matplotlib's init.py file in the get_data_path() routine. Specifically, right before raising the error at the end, I added the following code

   1       # CODE ADDED TO SUPPORT PY2EXE
   2       if sys.frozen:
   3          path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlib')
   4          return path

Special content for setup.py to use matplotlib

We also need to make sure we get the matplotlib subdirectory created in the distribution. This is where we'll include all of the stuff matplotlib includes in the pythonXX\share\matplotlib directory. This is also where the init file has been updated to look for this information.

   1 # We need to import the glob module to search for all files.
   2 import glob
   3 
   4 # We need to exclude matplotlib backends not being used by this executable.
   5 # You may find that you need different excludes to create a working executable with your chosen backend
   6 opts = {
   7     'py2exe': { 'excludes': ['_gtkagg', '_tkagg'],
   8                 'dll_excludes': ['libgdk-win32-2.0-0.dll',
   9                                  'libgobject-2.0-0.dll']}
  10 
  11 setup(
  12     # Additional data files required by matplotlib.  
  13     # Note that the glob.glob routine doesn't seem to pick up
  14     # the .matplotlib resource file, so I copy that separately.
  15     data_files = [('matplotlib', glob.glob(r'c:\python23\share\matplotlib\*')),
  16                   ('matplotlib', [r'c:\python23\share\matplotlib\.matplotlibrc'])],
  17 
  18     # Name and description of the program to create
  19     name = 'demo'
  20     description = 'MatPlotLib Demo Program'
  21 
  22     # Targets to build
  23     console = ['demo.py']
  24     )

MatPlotLib (last edited 2018-10-31 15:57:34 by JimmyRetzlaff)