Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c1134bd

Browse files
committed
updated references to mpl data directories for py2exe
svn path=/trunk/matplotlib/; revision=4654
1 parent af90581 commit c1134bd

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2007-12-06 updated references to mpl data directories for py2exe - DSD
2+
13
2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD
24

35
===============================================================

lib/matplotlib/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,16 @@ def _get_data_path():
428428

429429
# py2exe zips pure python, so still need special check
430430
if getattr(sys,'frozen',None):
431-
path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')
431+
path = os.path.join(os.path.split(sys.path[0])[0], 'mpl-data')
432+
if os.path.isdir(path): return path
433+
else:
434+
# Try again assuming we need to step up one more directory
435+
path = os.path.join(os.path.split(os.path.split(sys.path[0])[0])[0],
436+
'mpl-data')
432437
if os.path.isdir(path): return path
433438
else:
434439
# Try again assuming sys.path[0] is a dir not a exe
435-
path = os.path.join(sys.path[0], 'matplotlibdata')
440+
path = os.path.join(sys.path[0], 'mpl-data')
436441
if os.path.isdir(path): return path
437442

438443
raise RuntimeError('Could not find the matplotlib data files')
@@ -442,7 +447,8 @@ def _get_data_path_cached():
442447
defaultParams['datapath'][0] = _get_data_path()
443448
return defaultParams['datapath'][0]
444449

445-
get_data_path = verbose.wrap('matplotlib data path %s', _get_data_path_cached, always=False)
450+
get_data_path = verbose.wrap('matplotlib data path %s', _get_data_path_cached,
451+
always=False)
446452

447453
def get_py2exe_datafiles():
448454
datapath = get_data_path()
@@ -454,8 +460,8 @@ def get_py2exe_datafiles():
454460
if 'Matplotlib.nib' in files:
455461
files.remove('Matplotlib.nib')
456462
files = [os.path.join(root, filename) for filename in files]
457-
root = root.replace(tail, 'matplotlibdata')
458-
root = root[root.index('matplotlibdata'):]
463+
root = root.replace(tail, 'mpl-data')
464+
root = root[root.index('mpl-data'):]
459465
d[root] = files
460466
return d.items()
461467

lib/matplotlib/config/cutils.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _get_configdir():
7777
if os.path.exists(p):
7878
if not is_writable_dir(p):
7979
raise RuntimeError("""\
80-
'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir.
80+
'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir.
8181
You can also set environment variable MPLCONFIGDIR to any writable directory
8282
where you want matplotlib data stored """%h)
8383
else:
@@ -110,11 +110,16 @@ def _get_data_path():
110110

111111
# py2exe zips pure python, so still need special check
112112
if getattr(sys,'frozen',None):
113-
path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')
113+
path = os.path.join(os.path.split(sys.path[0])[0], 'mpl-data')
114+
if os.path.isdir(path): return path
115+
else:
116+
# Try again assuming we need to step up one more directory
117+
path = os.path.join(os.path.split(os.path.split(sys.path[0])[0])[0],
118+
'mpl-data')
114119
if os.path.isdir(path): return path
115120
else:
116121
# Try again assuming sys.path[0] is a dir not a exe
117-
path = os.path.join(sys.path[0], 'matplotlibdata')
122+
path = os.path.join(sys.path[0], 'mpl-data')
118123
if os.path.isdir(path): return path
119124

120125
raise RuntimeError('Could not find the matplotlib data files')
@@ -136,8 +141,8 @@ def get_py2exe_datafiles():
136141
if 'Matplotlib.nib' in files:
137142
files.remove('Matplotlib.nib')
138143
files = [os.path.join(root, filename) for filename in files]
139-
root = root.replace(tail, 'matplotlibdata')
140-
root = root[root.index('matplotlibdata'):]
144+
root = root.replace(tail, 'mpl-data')
145+
root = root[root.index('mpl-data'):]
141146
d[root] = files
142147
return d.items()
143148

0 commit comments

Comments
 (0)