Size: 2716
Comment: Updated for newer versions of matplotlib
|
Size: 204
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Introduction = [http://matplotlib.sf.net MatPlotLib] is a module to produce nice-looking plots in Python using a wide variety of back-end packages, at least one of which is likely to be available for your system. This ability to do things in a generic fashion makes this a simple system to use, but it gets complicated if you wish to distribute an executable instead of scripts. This page describes what I had to do to make matplotlib work with py2exe. = Special content for setup.py to use matplotlib = {{{ #!python # We need to import the glob module to search for all files. import glob # We need to exclude matplotlib backends not being used by this executable. You may find # that you need different excludes to create a working executable with your chosen backend. # We also need to include matplotlib.numerix.random_array opts = { 'py2exe': { 'includes': 'matplotlib.numerix.random_array', 'excludes': ['_gtkagg', '_tkagg'], 'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll'] } } # Additional data files are required by matplotlib. Note that the glob.glob routine # doesn't seem to pick up the .matplotlib resource file, so I copy that separately. # Do the same if you need to setup( data_files = [(r'matplotlibdata', glob.glob(r'c:\python24\share\matplotlib\*')), (r'matplotlibdata', [r'c:\python24\share\matplotlib\.matplotlibrc'])], name = 'demo', description = 'MatPlotLib Demo Program', console = ['demo.py'] ) }}} = Copying PyTZ folder = Now copy pytz folder from C:\Python24\Lib\site-packages to your dist/ folder and you're done! = Update for newer versions of matplotlib = Recent versions of matplotlib (this is tested with 0.87) have changed the location where data files are found. Here is a sample setup.py that works with simple matplotlib samples. It produces massive distributions - more work needs to be done on how to exclude unused backends. {{{ #!python from distutils.core import setup import py2exe from distutils.filelist import findall import os import matplotlib matplotlibdatadir = matplotlib.get_data_path() matplotlibdata = findall(matplotlibdatadir) matplotlibdata_files = [] for f in matplotlibdata: dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:]) matplotlibdata_files.append((os.path.split(dirname)[0], [f])) setup( console=['test.py'], options={ 'py2exe': { 'packages' : ['matplotlib', 'pytz'], } }, data_files=matplotlibdata_files ) }}} |
Im Madelaine and was born on 3 November 1990. My hobbies are Parkour and Tai Chi.<<<BR>> ><<<BR>> > <<<BR>> ><<<BR>> > My weblog: pay off credit card ([[https://www.trubeta.com/|www.trubeta.com]]) |
Im Madelaine and was born on 3 November 1990. My hobbies are Parkour and Tai Chi.<
><
> <
><
> My weblog: pay off credit card (www.trubeta.com)