trac-admin(ja-trac-0.9.6_3 ports)でSyntaxError: from __future__ imports must occur at the beginning of the fileが出たら

解決策いろいろ

今回は「解決策1」でスクリプトを直接修正することにした。

経緯

ja-trac-0.9.6_3(ports) on FreeBSD 6.1-Release で trac-admin を使おうとすると以下のようなエラーが出た。

[foo@bar~]$ trac-admin
Traceback (most recent call last):
  File "/usr/local/bin/trac-admin", line 21, in 
    from trac.scripts.admin import run
  File "/usr/local/lib/python2.5/site-packages/trac/scripts/admin.py", line 17
    from __future__ import generators
SyntaxError: from __future__ imports must occur at the beginning of the file
[foo@barh~]$ 

Trac公式BTSにも同様のメッセージがあった。

どうやら0.9.7で直っているらしいが現時点でのportsのjapanese/tracの最新は0.9.6_3なので更新できない。

そこで、0.9.7での修正内容を見て手動で反映させることにした。

/usr/local/lib/python2.5/site-packages/trac/scripts/admin.py の17行目にある from __future__ import generators を 15行目に移動して保存。

trac-adminを起動。無事動いた。