From e78c0d3b1e4c0f0152776981f4e3d33364243d08 Mon Sep 17 00:00:00 2001 From: Alastair Pharo Date: Fri, 11 Jan 2013 22:46:55 +1100 Subject: [PATCH] Support for 'python2' executable This fix is needed to make the gem compile on Arch Linux. --- ext/libv8/builder.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ext/libv8/builder.rb b/ext/libv8/builder.rb index 3ce94255..1d6c71fa 100644 --- a/ext/libv8/builder.rb +++ b/ext/libv8/builder.rb @@ -26,6 +26,22 @@ def make_flags(*flags) def build_libv8! Dir.chdir(File.expand_path '../../../vendor/v8', __FILE__) do + # Replace all mentions of "python" with "python2" if the executable + # is in the path. This is an issue for Arch Linux, which is also + # where the following fix comes from. + # See: https://projects.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/v8 + if system('which python2') && + !File.open('Makefile', 'r').read.include?('python2') + system <<-'EOF' + find build/ test/ tools/ src/ -type f \ + -exec sed -e 's_^#!/usr/bin/env python$_&2_' \ + -e 's_^\(#!/usr/bin/python2\).[45]$_\1_' \ + -e 's_^#!/usr/bin/python$_&2_' \ + -e "s_'python'_'python2'_" -i {} \; + EOF + system "sed -i 's/python /python2 /' Makefile" + end + puts `env CXX=#{compiler} LINK=#{compiler} #{make} #{make_flags}` end return $?.exitstatus