diff options
| author | Mike McQuaid | 2014-03-07 18:03:54 +0000 | 
|---|---|---|
| committer | Mike McQuaid | 2014-03-12 13:56:27 +0000 | 
| commit | 34edc35b9bfef8e68909d8bd90082a67d7fc4955 (patch) | |
| tree | 6f317031e83b2cb1f445f4e4dce55bba378c0926 /Library/Homebrew/language/python.rb | |
| parent | d8ef8d4f82417459af359109d33d2d2a4e1cb693 (diff) | |
| download | brew-34edc35b9bfef8e68909d8bd90082a67d7fc4955.tar.bz2 | |
Add Language::Python module.
Diffstat (limited to 'Library/Homebrew/language/python.rb')
| -rw-r--r-- | Library/Homebrew/language/python.rb | 26 | 
1 files changed, 26 insertions, 0 deletions
| diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb new file mode 100644 index 000000000..c35dde488 --- /dev/null +++ b/Library/Homebrew/language/python.rb @@ -0,0 +1,26 @@ +require "utils.rb" + +module Language +  module Python +    def self.major_minor_version python +      version = /\d\.\d/.match `#{python} --version 2>&1` +      return unless version +      Version.new(version.to_s) +    end + +    def self.each_python build, &block +      original_pythonpath = ENV["PYTHONPATH"] +      ["python", "python3"].each do |python| +        next if build.without? python +        version = self.major_minor_version python +        ENV["PYTHONPATH"] = if Formula.factory(python).installed? +          nil +        else +          "#{HOMEBREW_PREFIX}/lib/python#{version}/site-packages" +        end +        block.call python, version if block +      end +      ENV["PYTHONPATH"] = original_pythonpath +    end +  end +end | 
