The PGF backend only works on python2.7 and + #1173

Closed
NelleV opened this Issue Aug 30, 2012 · 4 comments

4 participants

@NelleV

The pgf backend relies on a new feature of the subprocess module from python2.7: subprocess.check_output; This command is basically like runs, but returns the outputs as a bytestring.

I'll provide a patch for that.

Here's the traceback of the failing tests:

ERROR: main.test_rcupdate

Traceback (most recent call last):
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/nose/case.py", line 197, in runTest
self.test(self.arg)
File "tests/test_backend_pgf.py", line 45, in backend_switcher
result = func(
args, *kwargs)
File "tests/test_backend_pgf.py", line 131, in test_rcupdate
compare_figure('pgf_rcupdate%d.pdf' % (i+1))
File "tests/test_backend_pgf.py", line 56, in compare_figure
plt.savefig(actual)
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/pyplot.py", line 475, in savefig
return fig.savefig(
args, *kwargs)
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/figure.py", line 1267, in savefig
self.canvas.print_figure(
args, *kwargs)
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/backend_bases.py", line 2091, in print_figure
*
kwargs)
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/backends/backend_pgf.py", line 743, in print_pdf
self._print_pdf_to_fh(fh)
File "/bioinfo/users/nvaroqua/Projects/matplotlib/env/lib/python2.6/site-packages/matplotlib/backends/backend_pgf.py", line 722, in _print_pdf_to_fh
subprocess.check_output(cmdargs, stderr=subprocess.STDOUT)
AttributeError: 'module' object has no attribute 'check_output'

@pelson
Matplotlib Developers member

Does anyone actually use python2.6 anymore? [expecting a grilling now ;-) ].

Will be a simple one to fix at least. @NelleV: Are you willing to work on this?

@NelleV

@pelson yep, working on it right now. i've got several options to fix the problem:

  1. use `check_call (which has been introduced in python2.5), but that implies have the standard output printed, and it's very ugly
  2. reimplement check_output in some way, and use this implementation
  3. use the scikit-learn's trick of copy pasting part of the stdlib in a utils module, and redirect the import when python2.6 stops being supported by matplotlib.

I'm in favor of the last one, as it's not much work for me (copy pasting 10lines of code from the python2.7 stdlib) :)

(and I actually have server's running with python 2.3.4 and python 2.4 :) )

@pwuertz

Uh, sorry about that.. I think I used check_output all over the place.

If this function is a problem for this release I would just stick to

proc = subprocess.Popen
proc.communicate()
check proc.returncode

but since NelleV seems to be working on this already let's see what he comes up with :)

@NelleV

@pwuertz it was only used in the pgf backend, so it was very quick to fix. I think other backend might benefit from this method too, so having a nice common method seems like a good idea!

@efiring efiring pushed a commit that closed this issue Sep 1, 2012
@NelleV NelleV closes #1173 - backporting python2.7 subprocess's check_output to be …
…able to support python 2.6
0a0ac8c
@efiring efiring closed this in 0a0ac8c Sep 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment