forked from Homebrew/legacy-homebrew
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cbf90d
commit 23818b3
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |