読者です 読者をやめる 読者になる 読者になる

うまいぼうぶろぐ

linuxとhttpdとperlのメモ

sphinx make pdf でエラーになる件

python, sphinx のversion上げたらmake pdf でエラーになった

$ make pdf
sphinx-build -b pdf -d build/doctrees   source build/pdf
Running Sphinx v1.1.2
loading pickled environment... done
building [pdf]: targets for 12 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
processing index... index overview hardware netapp switch hosts host-os virt-os manage-pc watcher utils virt-man
ager test
resolving references...
done
writing index... [ERROR] pdfbuilder.py:129 get_language() takes exactly 2 arguments (1 given)
Traceback (most recent call last):
	File "/usr/local/lib/python2.7/site-packages/rst2pdf-0.16-py2.7.egg/rst2pdf/pdfbuilder.py", line 126, in write
	  docwriter.write(doctree, destination)
	File "/usr/local/lib/python2.7/site-packages/docutils-0.8.1-py2.7.egg/docutils/writers/__init__.py", line 77, in write
	  self.translate()
	File "/usr/local/lib/python2.7/site-packages/rst2pdf-0.16-py2.7.egg/rst2pdf/pdfbuilder.py", line 533, in translate
	  langmod = languages.get_language('en')
TypeError: get_language() takes exactly 2 arguments (1 given)
FAILED
build succeeded.

Build finished. The PDF files are in build/pdf.

困っていたけど誰かが解決してくれていた。

ここを参考にして/usr/local/lib/python2.7/site-packages/docutils-0.8.1-py2.7.egg/docutils/languages/__init__.py
の18行目を

def get_language(language_code, reporter=None):

と書き換えて無事完了。

追記

何か気がついたらまた別のエラーが出るようになってた。

$ make pdf
sphinx-build -b pdf -d build/doctrees   source build/pdf
Running Sphinx v1.1.2
loading pickled environment... done
building [pdf]: targets for 17 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
processing index... index
resolving references...
done
writing index... [ERROR] pdfbuilder.py:129 FragLine instance has no attribute 'lineBreak'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/rst2pdf-0.16-py2.7.egg/rst2pdf/pdfbuilder.py", line 126, in write
    docwriter.write(doctree, destination)
  (略)
    dpl( tx, offset, lines[0], noJustifyLast and nLines==1)
  File "/usr/local/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-i686.egg/reportlab/platypus/paragraph.py", line 335, in _justifyDrawParaLineX
    simple = last or abs(extraSpace)<=1e-8 or line.lineBreak
AttributeError: FragLine instance has no attribute 'lineBreak'
FAILED
build succeeded.

Build finished. The PDF files are in build/pdf.

build successded と出てるけどbuild/pdf/index.pdf のsizeは0になる。

参考にしてreportlab-*/reportlab/platypus/paragraph.py を修正。

# diff -u /usr/local/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-i686.egg/reportlab/platypus/paragraph.py.20120611 /usr/local/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-i686.egg/reportlab/platypus/paragraph.py
--- /usr/local/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-i686.egg/reportlab/platypus/paragraph.py.20120611  2012-06-11 14:15:38.000000000 +0900
+++ /usr/local/lib/python2.7/site-packages/reportlab-2.5-py2.7-linux-i686.egg/reportlab/platypus/paragraph.py   2012-06-11 14:15:54.000000000 +0900
@@ -332,7 +332,7 @@
 def _justifyDrawParaLineX( tx, offset, line, last=0):
     setXPos(tx,offset)
     extraSpace = line.extraSpace
-    simple = last or abs(extraSpace)<=1e-8 or line.lineBreak
+    simple = last or abs(extraSpace)<=1e-8 or getattr(line, 'lineBreak', False)
     if not simple:
         nSpaces = line.wordCount+sum([_nbspCount(w.text) for w in line.words if not hasattr(w,'cbDefn')])-1
         simple = not nSpaces