Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decode the execution path string based file system encoding #4343

Merged
merged 6 commits into from Apr 19, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/matplotlib/__init__.py
Expand Up @@ -653,6 +653,13 @@ def _get_cachedir():
get_cachedir = verbose.wrap('CACHEDIR=%s', _get_cachedir, always=False)


def _decode_filesystem_path(path):
if isinstance(path, bytes):
return path.decode(sys.getfilesystemencoding())
else:
return path


def _get_data_path():
'get the path to matplotlib data'

Expand All @@ -663,20 +670,22 @@ def _get_data_path():
'directory')
return path

path = os.sep.join([os.path.dirname(__file__), 'mpl-data'])
_file = _decode_filesystem_path(__file__)
path = os.sep.join([os.path.dirname(_file), 'mpl-data'])
if os.path.isdir(path):
return path

# setuptools' namespace_packages may highjack this init file
# so need to try something known to be in matplotlib, not basemap
import matplotlib.afm
path = os.sep.join([os.path.dirname(matplotlib.afm.__file__), 'mpl-data'])
_file = _decode_filesystem_path(matplotlib.afm.__file__)
path = os.sep.join([os.path.dirname(_file), 'mpl-data'])
if os.path.isdir(path):
return path

# py2exe zips pure python, so still need special check
if getattr(sys, 'frozen', None):
exe_path = os.path.dirname(sys.executable)
exe_path = os.path.dirname(_decode_filesystem_path(sys.executable))
path = os.path.join(exe_path, 'mpl-data')
if os.path.isdir(path):
return path
Expand Down