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:
Max Howell 2010-01-13 09:00:24 +00:00
parent df79d74e13
commit 9f871c9955
2 changed files with 35 additions and 9 deletions

View File

@ -289,6 +289,10 @@ class Formula
self.class.deps or []
end
def external_deps
self.class.external_deps
end
protected
# Pretty titles the command and buffers stdout/stderr
# Throws if there's an error
@ -460,7 +464,7 @@ private
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
if specs
@ -474,26 +478,31 @@ private
args.each { |item| @aliases << item.to_s }
end
def depends_on name, *args
def depends_on name
@deps ||= []
@external_deps ||= {:python => [], :ruby => [], :perl => []}
case name
when String
# noop
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
name = name.to_s
when Formula
@deps << name
return # we trust formula dev to not dupe their own instantiations
# noop
else
raise "Unsupported type #{name.class}"
end
# we get duplicates because every new fork of this process repeats this
# step for some reason I am not sure about
@deps << name unless @deps.include? name
@deps << name
end
def skip_clean paths

View File

@ -20,10 +20,27 @@ class FormulaInstaller
end
deps
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:
#{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|
begin
check_external_deps f
install_private dep unless dep.installed?
rescue
#TODO continue if this is an optional dep