Adds: depends_on 'simplejson' => :python
So far we only added python, but we can add more. Fixes Homebrew/homebrew#401
This commit is contained in:
parent
df79d74e13
commit
9f871c9955
@ -289,6 +289,10 @@ class Formula
|
|||||||
self.class.deps or []
|
self.class.deps or []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def external_deps
|
||||||
|
self.class.external_deps
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
# Pretty titles the command and buffers stdout/stderr
|
# Pretty titles the command and buffers stdout/stderr
|
||||||
# Throws if there's an error
|
# Throws if there's an error
|
||||||
@ -460,7 +464,7 @@ private
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_rw :url, :version, :homepage, :specs, :deps, :aliases, *CHECKSUM_TYPES
|
attr_rw :url, :version, :homepage, :specs, :deps, :external_deps, :aliases, *CHECKSUM_TYPES
|
||||||
|
|
||||||
def head val=nil, specs=nil
|
def head val=nil, specs=nil
|
||||||
if specs
|
if specs
|
||||||
@ -474,26 +478,31 @@ private
|
|||||||
args.each { |item| @aliases << item.to_s }
|
args.each { |item| @aliases << item.to_s }
|
||||||
end
|
end
|
||||||
|
|
||||||
def depends_on name, *args
|
def depends_on name
|
||||||
@deps ||= []
|
@deps ||= []
|
||||||
|
@external_deps ||= {:python => [], :ruby => [], :perl => []}
|
||||||
|
|
||||||
case name
|
case name
|
||||||
when String
|
when String
|
||||||
# noop
|
# noop
|
||||||
when Hash
|
when Hash
|
||||||
name = name.keys.first # indeed, we only support one mapping
|
key, value = name.shift
|
||||||
|
case value
|
||||||
|
when :python, :ruby, :perl
|
||||||
|
@external_deps[value] << key
|
||||||
|
return
|
||||||
|
when :optional, :recommended
|
||||||
|
name = key
|
||||||
|
end
|
||||||
when Symbol
|
when Symbol
|
||||||
name = name.to_s
|
name = name.to_s
|
||||||
when Formula
|
when Formula
|
||||||
@deps << name
|
# noop
|
||||||
return # we trust formula dev to not dupe their own instantiations
|
|
||||||
else
|
else
|
||||||
raise "Unsupported type #{name.class}"
|
raise "Unsupported type #{name.class}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# we get duplicates because every new fork of this process repeats this
|
@deps << name
|
||||||
# step for some reason I am not sure about
|
|
||||||
@deps << name unless @deps.include? name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip_clean paths
|
def skip_clean paths
|
||||||
|
|||||||
@ -20,10 +20,27 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
deps
|
deps
|
||||||
end
|
end
|
||||||
|
def pyerr dep
|
||||||
|
brew_pip = ' brew install pip &&' unless Formula.factory('pip').installed?
|
||||||
|
<<-EOS
|
||||||
|
Unsatisfied dependency, #{dep}
|
||||||
|
Homebrew does not provide formula for Python dependencies, pip does:
|
||||||
|
|
||||||
def install f
|
#{brew_pip} pip install #{dep}
|
||||||
|
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_external_deps f
|
||||||
|
f.external_deps[:python].each do |dep|
|
||||||
|
raise pyerr(dep) unless quiet_system "/usr/bin/python", "-c", "import #{dep}"
|
||||||
|
end if f.external_deps
|
||||||
|
end
|
||||||
|
|
||||||
|
def install f
|
||||||
expand_deps(f).each do |dep|
|
expand_deps(f).each do |dep|
|
||||||
begin
|
begin
|
||||||
|
check_external_deps f
|
||||||
install_private dep unless dep.installed?
|
install_private dep unless dep.installed?
|
||||||
rescue
|
rescue
|
||||||
#TODO continue if this is an optional dep
|
#TODO continue if this is an optional dep
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user