{"action":"created","issue":{"url":"https://api.github.com/repos/timj/starlink-pyast/issues/14","repository_url":"https://api.github.com/repos/timj/starlink-pyast","labels_url":"https://api.github.com/repos/timj/starlink-pyast/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/timj/starlink-pyast/issues/14/comments","events_url":"https://api.github.com/repos/timj/starlink-pyast/issues/14/events","html_url":"https://github.com/timj/starlink-pyast/issues/14","id":180964734,"number":14,"title":"Matplotlib dependency not listed in setup.py","user":{"login":"rmjarvis","id":623887,"avatar_url":"https://avatars.githubusercontent.com/u/623887?v=3","gravatar_id":"","url":"https://api.github.com/users/rmjarvis","html_url":"https://github.com/rmjarvis","followers_url":"https://api.github.com/users/rmjarvis/followers","following_url":"https://api.github.com/users/rmjarvis/following{/other_user}","gists_url":"https://api.github.com/users/rmjarvis/gists{/gist_id}","starred_url":"https://api.github.com/users/rmjarvis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmjarvis/subscriptions","organizations_url":"https://api.github.com/users/rmjarvis/orgs","repos_url":"https://api.github.com/users/rmjarvis/repos","events_url":"https://api.github.com/users/rmjarvis/events{/privacy}","received_events_url":"https://api.github.com/users/rmjarvis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-04T18:09:47Z","updated_at":"2016-10-12T17:39:04Z","closed_at":null,"body":"When setting up Travis CI for GalSim, I discovered that starlink-pyast has a hidden dependency of matplotlib at the top of Grf.py.  Since none of the other packages we use in GalSim require matplotlib, it didn't get installed on the Travis sandbox, and `import starlink.Atl` led to an `ImportError` from the matplotlib dependency.\r\n\r\nEven with matplotlib installed, it's still an annoying import, since it has to set up the font cache the first time it is imported.  This takes time and adds noise to the output:\r\n```\r\n/home/travis/virtualenv/python2.7.12/lib/python2.7/site-packages/matplotlib/font_manager.py:273:\r\nUserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.\r\n  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')\r\n```\r\n\r\nPossible solutions in order of (my) preference:\r\n1. Make matplotlib an optional dependency and only import Grf (and thus matplotlib) if the user calls `Atl.plotframeset`.  i.e. Move the line `import starlink.Grf as Grf` into this function.\r\n2. Make matplotlib an optional dependency and only import matplotlib in the Grf functions that use it.  Then `import starlink.Grf as Grf` is quick, and matplotlib would only have to be imported if the user calls the functions in Grf that need it.\r\n3. Make matplotlib an official dependency by adding it to setup.py, but also do (1) or (2) to avoid the above warning.\r\n4. Make matplotlib an official dependency, and continue to needlessly `import matplotlib` whenever Atl is imported.\r\n\r\nThanks for your consideration.  :)"},"comment":{"url":"https://api.github.com/repos/timj/starlink-pyast/issues/comments/253283782","html_url":"https://github.com/timj/starlink-pyast/issues/14#issuecomment-253283782","issue_url":"https://api.github.com/repos/timj/starlink-pyast/issues/14","id":253283782,"user":{"login":"timj","id":60622,"avatar_url":"https://avatars.githubusercontent.com/u/60622?v=3","gravatar_id":"","url":"https://api.github.com/users/timj","html_url":"https://github.com/timj","followers_url":"https://api.github.com/users/timj/followers","following_url":"https://api.github.com/users/timj/following{/other_user}","gists_url":"https://api.github.com/users/timj/gists{/gist_id}","starred_url":"https://api.github.com/users/timj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timj/subscriptions","organizations_url":"https://api.github.com/users/timj/orgs","repos_url":"https://api.github.com/users/timj/repos","events_url":"https://api.github.com/users/timj/events{/privacy}","received_events_url":"https://api.github.com/users/timj/received_events","type":"User","site_admin":false},"created_at":"2016-10-12T17:39:04Z","updated_at":"2016-10-12T17:39:04Z","body":"Hmmm. Yes, I tend to prefer imports at the top of code files rather than buried in the middle, but in this case, given that the failure mode is identical (you get an unexpected error some time after your program starts rather than at import time), I guess having the real error trigger inside `plotframeset` is better than an error we make up ourselves when `plotframeset` is called."}}
{"actor":{"display_login":"timj"}}