Issue #786 resolved

Doesn't install with Jython

idalton
created an issue

I'm using Jython 2.7a2, the latest.

I've set up a Jython virtualenv, and run 'pip install pygments'. It fails at the following stage:

byte-compiling /home/ian/Applications/jython-env/Lib/site-packages/pygments/lexers/_vimbuiltins.py to _vimbuiltins$py.class

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ian/Applications/jython-env/build/pygments/setup.py", line 61, in <module>
    setup(
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/ian/Applications/jython-env/Lib/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/install.py", line 56, in run
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/command/install.py", line 517, in run
    self.run_command(cmd_name)
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/ian/Applications/jython-env/Lib/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/install_lib.py", line 24, in run
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/command/install_lib.py", line 136, in byte_compile
    byte_compile(files, optimize=0,
  File "/home/ian/Applications/jython2.7a2/Lib/distutils/util.py", line 567, in byte_compile
    compile(file, cfile, dfile)
  File "/home/ian/Applications/jython2.7a2/Lib/py_compile.py", line 96, in compile
    _py_compile.compile(file, cfile, dfile)
  File "/home/ian/Applications/jython2.7a2/Lib/py_compile.py", line 96, in compile
    _py_compile.compile(file, cfile, dfile)
        at org.python.objectweb.asm.MethodWriter.a(Unknown Source)
        at org.python.objectweb.asm.ClassWriter.toByteArray(Unknown Source)
        at org.python.compiler.ClassFile.write(ClassFile.java:124)
        at org.python.compiler.Module.write(Module.java:618)
        at org.python.compiler.Module.compile(Module.java:674)
        at org.python.core.imp.compileSource(imp.java:330)
        at org.python.core.imp.compileSource(imp.java:252)
        at org.python.modules._py_compile.compile(_py_compile.java:28)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)

java.lang.RuntimeException: java.lang.RuntimeException: Method code too large!

Jython can't compile methods over a certain size. One solution is to import pycimport; this requires that a pyc file has been generated by CPython.

Comments (12)

  1. Tim Hatch

    Yes, it's actually a limitation of the JVM, not just Jython however. In this case, there's a fairly trivial workaround in a file that humans aren't intended to edit, so I think we should do it.

    ref: http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#88659

    _vimbuiltins.py defines several large tables, and those tables combined are too large for a single method in Java. Individually though, they're fine.

    Pushed http://code.timhatch.com/hg/pygments-tim/rev/913a59849ec1

  2. Thomas Mortagne

    Hi guys, note that I'm using Pygments from Java since a while but I'm still using Jython 2.5.3 and I don't have any issue. I just wrote http://pygments.org/docs/java/ to indicate how I use it if you want to check. Maybe there is something wrong in 2.7 or maybe it's with a parser or a serializer I never used myself yet (did ot checked the detail of your error).

  3. Thomas Mortagne

    Actually someone reported me that he had the exact same issue but only with the Vim language so it's not a general Pygments issue (not a Pygments issue at all anyway) but something Jython or the JVM does not like about one of the Vim lexer methods when converted to Java bytecode.

  4. Log in to comment