Allow specifying a custom PATH for which method
Closes Homebrew/homebrew#21794.
This commit is contained in:
parent
d5325eb4e4
commit
23fbe23426
@ -121,15 +121,9 @@ class PythonInstalled < Requirement
|
|||||||
# Note, we don't support homebrew/versions/pythonXX.rb, though.
|
# Note, we don't support homebrew/versions/pythonXX.rb, though.
|
||||||
Formula.factory(@name).opt_prefix/"bin/python#{@min_version.major}"
|
Formula.factory(@name).opt_prefix/"bin/python#{@min_version.major}"
|
||||||
else
|
else
|
||||||
begin
|
# Using the ORIGINAL_PATHS here because in superenv, the user
|
||||||
# Using the ORIGINAL_PATHS here because in superenv, the user
|
# installed external Python is not visible otherwise.
|
||||||
# installed external Python is not visible otherwise.
|
which(@name, ORIGINAL_PATHS.join(':'))
|
||||||
tmp_PATH = ENV['PATH']
|
|
||||||
ENV['PATH'] = ORIGINAL_PATHS.join(':')
|
|
||||||
which(@name)
|
|
||||||
ensure
|
|
||||||
ENV['PATH'] = tmp_PATH
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -166,8 +166,8 @@ def puts_columns items, star_items=[]
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def which cmd
|
def which cmd, path=ENV['PATH']
|
||||||
dir = ENV['PATH'].split(':').find {|p| File.executable? File.join(p, cmd)}
|
dir = path.split(':').find {|p| File.executable? File.join(p, cmd)}
|
||||||
Pathname.new(File.join(dir, cmd)) unless dir.nil?
|
Pathname.new(File.join(dir, cmd)) unless dir.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user