Skip to content
Snippets Groups Projects
Commit 84c69a16 authored by Aman Gupta's avatar Aman Gupta
Browse files

Merge pull request #74 from charliesome/detect-python-vs-python2

Detect if `python2` is available or else fall back to `python`
parents 9604a54a f03df350
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -36,12 +36,21 @@ module Pygments
 
# A pipe to the mentos python process. #popen4 gives us
# the pid and three IO objects to write and read.
script = File.expand_path('../mentos.py', __FILE__)
script = 'python ' + script if is_windows
script = "#{python_binary} #{File.expand_path('../mentos.py', __FILE__)}"
@pid, @in, @out, @err = popen4(script)
@log.info "[#{Time.now.iso8601}] Starting pid #{@pid.to_s} with fd #{@out.to_i.to_s}."
end
 
# Detect a suitable Python binary to use. We can't just use `python2`
# because apparently some old versions of Debian only have `python` or
# something like that.
def python_binary
@python_binary ||= begin
`which python2`
$?.success? ? "python2" : "python"
end
end
# Stop the child process by issuing a kill -9.
#
# We then call waitpid() with the pid, which waits for that particular
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment