pygments / pygments.rb

💎 Ruby wrapper for Pygments syntax highlighter
MIT License
572 stars 141 forks source link

Add Python 3 support for pygments.rb #72

Closed soimort closed 11 years ago

soimort commented 11 years ago

This PR adds fully support for Python 3, which could solve all those annoying Python 3-related issues (especially on a distro where the default python is 3.x, like Gentoo or Arch. after tired of the temporary #!/usr/bin/env python2 hack.):

45, #49, #58, #59

mentos.py is now made runnable under both Python 2 and 3.

On a system where the default python is 2.x, vendor/pygments-main will be bundled unchanged as before. When the default python is 3.x, the code in vendor/pygments-main will be run through 2to3 after gem installed (just as the installation of Python 3 Pygments did), using ext/extconf.rb.

The only thing I didn't port is the test part, due to the original vendor code is Python 2 only. There's no way to test it on Python 3 without running it through 2to3.

To test it on a Python 3-default system, build and install the gem first, then change a line in popen.rb to something like: (for using the 2to3-ported vendor code)

ENV['PYGMENTS_PATH'] = '/home/user/.rvm/gems/ruby-2.0.0-p0/gems/pygments.rb-x.y.z/'

then all tests shall pass.

tmm1 commented 11 years ago

Clever.

tnm commented 11 years ago

Should be resolved in latest release.