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

Update pyplots.py #132

Merged
merged 1 commit into from Feb 2, 2016
Merged

Update pyplots.py #132

merged 1 commit into from Feb 2, 2016

Conversation

@ltiao
Copy link
Contributor

ltiao commented Feb 2, 2016

First, we successfully install the pyplots plugin as instructed:

$ nikola plugin -i pyplots
[2016-02-02T02:56:51Z] NOTICE: plugin: No site found, assuming --user
[2016-02-02T02:56:51Z] INFO: requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): plugins.getnikola.com
[2016-02-02T02:56:51Z] INFO: plugin: Downloading 'https://plugins.getnikola.com/v7/pyplots.zip'
[2016-02-02T02:56:51Z] INFO: requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): plugins.getnikola.com
[2016-02-02T02:56:52Z] INFO: plugin: Extracting: pyplots into /Users/tiao/.nikola/plugins/
[2016-02-02T02:56:52Z] NOTICE: plugin: This plugin has Python dependencies.
[2016-02-02T02:56:52Z] INFO: plugin: Installing dependencies with pip...
Collecting matplotlib (from -r /Users/tiao/.nikola/plugins/pyplots/requirements.txt (line 1))
  Downloading matplotlib-1.5.1-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (49.7MB)
    100% |████████████████████████████████| 49.7MB 11kB/s 
Collecting cycler (from matplotlib->-r /Users/tiao/.nikola/plugins/pyplots/requirements.txt (line 1))
  Downloading cycler-0.9.0-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in ./.virtualenvs/blog/lib/python3.5/site-packages (from matplotlib->-r /Users/tiao/.nikola/plugins/pyplots/requirements.txt (line 1))
Collecting pytz (from matplotlib->-r /Users/tiao/.nikola/plugins/pyplots/requirements.txt (line 1))
  Downloading pytz-2015.7-py2.py3-none-any.whl (476kB)
    100% |████████████████████████████████| 479kB 687kB/s 
Collecting numpy>=1.6 (from matplotlib->-r /Users/tiao/.nikola/plugins/pyplots/requirements.txt (line 1))
  Downloading numpy-1.10.4-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.7MB)
    100% |████████████████████████████████| 3.7MB 127kB/s 
Collecting pyparsing!=2.0.0,!=2.0.4,>=1.5.6 (from matplotlib->-r /Users/tiao/.nikola/plugins/pyplots/requirements.txt (line 1))
  Downloading pyparsing-2.0.7-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six in ./.virtualenvs/blog/lib/python3.5/site-packages (from cycler->matplotlib->-r /Users/tiao/.nikola/plugins/pyplots/requirements.txt (line 1))
Installing collected packages: cycler, pytz, numpy, pyparsing, matplotlib
Successfully installed cycler-0.9.0 matplotlib-1.5.1 numpy-1.10.4 pyparsing-2.0.7 pytz-2015.7
[2016-02-02T02:57:30Z] INFO: plugin: Dependency installation succeeded.

However, when we try to run, say nikola --help new_post we encounter the following error:

$ nikola --help new_post
[2016-02-02T03:01:52Z] ERROR: yapsy: Unable to import plugin: /Users/tiao/.nikola/plugins/pyplots/pyplots
Traceback (most recent call last):
  File "/Users/tiao/.virtualenvs/blog/lib/python3.5/site-packages/yapsy/PluginManager.py", line 488, in loadPlugins
    candidate_module = imp.load_module(plugin_module_name,plugin_file,candidate_filepath+".py",("py","r",imp.PY_SOURCE))
  File "/Users/tiao/.virtualenvs/blog/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/Users/tiao/.virtualenvs/blog/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/tiao/.nikola/plugins/pyplots/pyplots.py", line 57, in <module>
    pyplot_spec = directives.images.Image.option_spec
AttributeError: module 'docutils.parsers.rst.directives' has no attribute 'images'

Note that we are using docutils==0.12 here. Please also refer to: sphinx-doc/sphinx#1361

It appears the structure of the modules have changed, but we can circumvent this by importing images as separate module:

$ python
Python 3.5.1 (default, Dec 14 2015, 23:34:36) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from docutils.parsers.rst import directives
>>> class PyPlot(directives.images.Image):
...     pass
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'docutils.parsers.rst.directives' has no attribute 'images'
>>> from docutils.parsers.rst.directives import images
>>> class PyPlot(images.Image):
...     pass
... 

This PR makes the necessary changes to reflect the above.

Fixed importing of `docutils.parsers.rst.directives.images`
@Kwpolska
Copy link
Member

Kwpolska commented Feb 2, 2016

Thanks!

Kwpolska added a commit that referenced this pull request Feb 2, 2016
Update pyplots.py
@Kwpolska Kwpolska merged commit 67e3d85 into getnikola:master Feb 2, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ltiao ltiao deleted the ltiao:patch-1 branch Feb 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.