Add Language::Python module.
This commit is contained in:
parent
d8ef8d4f82
commit
34edc35b9b
26
Library/Homebrew/language/python.rb
Normal file
26
Library/Homebrew/language/python.rb
Normal file
@ -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
|
||||||
Loading…
x
Reference in New Issue
Block a user