I  have recently had a problem wrapping a script on a linux machine. The 
problem was with matplotlib and the path to  mpl-data.

The problem seemed to be with the cx_Freeze.hooks function

def load_matplotlib(finder, module):  # taken from cx_Freeze  5.1.1
    """the matplotlib module requires data to be found in mpl-data in the
       same directory as the frozen executable so oblige it"""
    dir = os.path.join(module.path[0], "mpl-data")
    finder.IncludeFiles(dir, "mpl-data")

that returned the incorrect path to the mpl-data on linux (at least on my Linux 
mint 18 machine). With a little cunning I was able to work around this problem 
but wonder if the load_matplotlib could be changed to avoid this issue.

Here is my offering for a solution.
The matplotlib package provides the function get_data_path to find the path to 
mpl-data - although this function does not seem to be well documented.

>>> matplotlib.get_data_path()
u'/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data'
>>> exit()
$ cd /usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data
$ ls
   fonts  images  lineprops.glade  matplotlibrc  sample_data  stylelib


so one could potentially write
def load_matplotlib(finder, module):
    """the matplotlib module requires data to be found in mpl-data in the
       same directory as the frozen executable so oblige it"""
     from matplotlib import get_data_path
  finder.IncludeFiles(get_data_path(), "mpl-data")

Alternatively, if you don't want to do the import  from matplotlib, one could 
reimplement the algorithm implemented in get_data_path
I hope that is of some use and apologize if there is a well-established bug 
reporting process that I should have used  - I looked but could not find one.

Dominic


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
cx-freeze-users mailing list
cx-freeze-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cx-freeze-users

Reply via email to