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

get_sample_data() in cbook.py duplicates code from _get_data_path() __init__.py #6536

Closed
2 of 3 tasks
rathann opened this issue Jun 5, 2016 · 3 comments
Closed
2 of 3 tasks
Assignees
Milestone

Comments

@rathann
Copy link

rathann commented Jun 5, 2016

To help us understand and resolve your issue please check that you have provided
the information below.

  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)

1.5.2rc2, python 2.7.11 and python 3.5.1, Fedora rawhide.

  • How did you install Matplotlib and Python (pip, anaconda, from source ...)

From source, I'm building a new version of the Fedora package.

  • If possible please supply a Short, Self Contained, Correct, Example
    that demonstrates the issue i.e a small piece of code which reproduces the issue
    and can be run with out any other (or as few as possible) external dependencies.

In Fedora, we're patching the lib/matplotlib/__init__.py to use /usr/share/matplotlib/mpl-data as the path for data files. cbook.py seems to have its own reimplementation of the data files path code, so the path needs to be patched in two locations. It would be nice if we could specify the desired data files location path at build time, by the way. Shall I open a separate issue for that?

Trivial patch:

--- a/lib/matplotlib/cbook.py   2016-05-20 14:14:52.000000000 +0200
+++ b/lib/matplotlib/cbook.py   2016-05-20 19:28:57.373601582 +0200
@@ -823,8 +823,7 @@ def get_sample_data(fname, asfileobj=Tru
     if matplotlib.rcParams['examples.directory']:
         root = matplotlib.rcParams['examples.directory']
     else:
-        root = os.path.join(os.path.dirname(__file__),
-                            "mpl-data", "sample_data")
+        root = os.path.join(matplotlib._get_data_path(), 'sample_data')
     path = os.path.join(root, fname)

     if asfileobj:
@tacaswell
Copy link
Member

👍 to that patch, can you open a PR?

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Jun 6, 2016
@rathann
Copy link
Author

rathann commented Jun 8, 2016

Sorry, I've been too busy. I'll try to open a PR (against master branch?) soon, but first I have to learn how to do it properly.

@tacaswell
Copy link
Member

no worries, if you are not familiar with the workflow I will take care of it.

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Jul 12, 2016
At request of fedora package maintainers.

closes matplotlib#6536
@tacaswell tacaswell self-assigned this Jul 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants