@@ -367,55 +367,63 @@ def _get_configdir():
367367
368368def _get_data_path ():
369369 'get the path to matplotlib data'
370-
371- if _have_pkg_resources :
372- try :
373- dist = pkg_resources .get_distribution ('matplotlib' )
374- except pkg_resources .DistributionNotFound :
375- # pkg_resources is installed, but setuptools wasn't used into install matplotlib.
376- used_setuptools_to_install_MPL = False
377- else :
378- used_setuptools_to_install_MPL = True
379-
380- if used_setuptools_to_install_MPL :
381- req = pkg_resources .Requirement .parse ('matplotlib' )
382- path = pkg_resources .resource_filename (req , 'share/matplotlib' )
383- return path
384-
370+
385371 if os .environ .has_key ('MATPLOTLIBDATA' ):
386372 path = os .environ ['MATPLOTLIBDATA' ]
387373 if os .path .isdir (path ): return path
374+
375+ else :
376+ path = os .sep .join ([os .path .dirname (__file__ ), 'mpl-data' ])
377+ if os .path .isdir (path ): return path
388378
389- path = os .path .join (distutils .sysconfig .PREFIX , 'share' , 'matplotlib' )
390- if os .path .isdir (path ): return path
391-
392- path = '/usr/local/share/matplotlib'
393- if os .path .isdir (path ): return path
394-
395- path = '/usr/share/matplotlib'
396- if os .path .isdir (path ): return path
397-
398- path = os .path .join (os .sep .join (__file__ .split (os .sep )[:- 1 ]),
399- 'share' ,'matplotlib' )
400- if os .path .isdir (path ): return path
401-
402- path = os .path .join (os .sep .join (__file__ .split (os .sep )[:- 5 ]),
403- 'share' ,'matplotlib' )
404- if os .path .isdir (path ): return path
405-
406- # CODE ADDED TO SUPPORT PY2EXE - you will need to copy
407- # C:\Python23\share\matplotlib into your dist dir. See
408- # http://starship.python.net/crew/theller/moin.cgi/MatPlotLib
409- # for more info
410-
411- if sys .platform == 'win32' and sys .frozen :
412- path = os .path .join (os .path .split (sys .path [0 ])[0 ], 'matplotlibdata' )
413- if os .path .isdir (path ): return path
414- else :
415- # Try again assuming sys.path[0] is a dir not a exe
416- path = os .path .join (sys .path [0 ], 'matplotlibdata' )
417- if os .path .isdir (path ): return path
418-
379+ # if _have_pkg_resources:
380+ # try:
381+ # dist = pkg_resources.get_distribution('matplotlib')
382+ # except pkg_resources.DistributionNotFound:
383+ # # pkg_resources is installed, but setuptools wasn't used into install matplotlib.
384+ # used_setuptools_to_install_MPL = False
385+ # else:
386+ # used_setuptools_to_install_MPL = True
387+ #
388+ # if used_setuptools_to_install_MPL:
389+ # req = pkg_resources.Requirement.parse('matplotlib')
390+ # path = pkg_resources.resource_filename(req, 'share/matplotlib')
391+ # return path
392+ #
393+ # if os.environ.has_key('MATPLOTLIBDATA'):
394+ # path = os.environ['MATPLOTLIBDATA']
395+ # if os.path.isdir(path): return path
396+ #
397+ # path = os.path.join(distutils.sysconfig.PREFIX, 'share', 'matplotlib')
398+ # if os.path.isdir(path): return path
399+ #
400+ # path = '/usr/local/share/matplotlib'
401+ # if os.path.isdir(path): return path
402+ #
403+ # path = '/usr/share/matplotlib'
404+ # if os.path.isdir(path): return path
405+ #
406+ # path = os.path.join(os.sep.join(__file__.split(os.sep)[:-1]),
407+ # 'share','matplotlib')
408+ # if os.path.isdir(path): return path
409+ #
410+ # path = os.path.join(os.sep.join(__file__.split(os.sep)[:-5]),
411+ # 'share','matplotlib')
412+ # if os.path.isdir(path): return path
413+ #
414+ # # CODE ADDED TO SUPPORT PY2EXE - you will need to copy
415+ # # C:\Python23\share\matplotlib into your dist dir. See
416+ # # http://starship.python.net/crew/theller/moin.cgi/MatPlotLib
417+ # # for more info
418+ #
419+ # if sys.platform=='win32' and sys.frozen:
420+ # path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')
421+ # if os.path.isdir(path): return path
422+ # else:
423+ # # Try again assuming sys.path[0] is a dir not a exe
424+ # path = os.path.join(sys.path[0], 'matplotlibdata')
425+ # if os.path.isdir(path): return path
426+ #
419427 raise RuntimeError ('Could not find the matplotlib data files' )
420428
421429get_data_path = verbose .wrap ('matplotlib data path %s' , _get_data_path , always = False )
0 commit comments