audit: remove deprecated Python features.

These will be removed soon so don't check for them.
This commit is contained in:
Mike McQuaid 2013-12-12 21:04:45 +00:00
parent 16aeb7bca4
commit 38d2ffb2b8

View File

@ -158,13 +158,6 @@ class FormulaAuditor
Don't use #{dep} as a dependency. We allow non-Homebrew Don't use #{dep} as a dependency. We allow non-Homebrew
#{dep} installations. #{dep} installations.
EOS EOS
when 'python', 'python2', 'python3'
problem <<-EOS.undent
Don't use #{dep} as a dependency (string).
We have special `depends_on :python` (or :python2 or :python3 )
that works with brewed and system Python and allows us to support
bindings for 2.x and 3.x in parallel and much more.
EOS
when 'gfortran' when 'gfortran'
problem "Use `depends_on :fortran` instead of `depends_on 'gfortran'`" problem "Use `depends_on :fortran` instead of `depends_on 'gfortran'`"
when 'open-mpi', 'mpich2' when 'open-mpi', 'mpich2'
@ -486,66 +479,6 @@ class FormulaAuditor
Symbol === dep ? dep.inspect : "'#{dep}'" Symbol === dep ? dep.inspect : "'#{dep}'"
end end
def audit_python
if text =~ /(def\s*)?which_python/
problem "Replace `which_python` by `python.xy`, which returns e.g. 'python2.7'"
end
if text =~ /which\(?["']python/
problem "Don't locate python with `which 'python'`, use `python.binary` instead"
end
if text =~ /LanguageModuleDependency.new\s?\(\s?:python/
problem <<-EOS.undent
Python: Replace `LanguageModuleDependency.new(:python,'PyPi-name','module')`
by the new `depends_on :python => ['module' => 'PyPi-name']`
EOS
end
# Checks that apply only to code in def install
if text =~ /(\s*)def\s+install((.*\n)*?)(\1end)/
install_body = $2
if install_body =~ /system\(?\s*['"]python/
problem "Instead of `system 'python', ...`, call `system python, ...`"
end
if text =~ /system\(?\s*python\.binary/
problem "Instead of `system python.binary, ...`, call `system python, ...`"
end
end
# Checks that apply only to code in def caveats
if text =~ /(\s*)def\s+caveats((.*\n)*?)(\1end)/ || text =~ /(\s*)def\s+caveats;(.*?)end/
caveats_body = $2
if caveats_body =~ /[ \{=](python[23]?)\.(.*\w)/
# So if in the body of caveats there is a `python.whatever` called,
# check that there is a guard like `if python` or similiar:
python = $1
method = $2
unless caveats_body =~ /(if python[23]?)|(if build\.with\?\s?\(?['"]python)|(unless build.without\?\s?\(?['"]python)/
problem "Please guard `#{python}.#{method}` like so `#{python}.#{method} if #{python}`"
end
end
end
unless f.requirements.any?{ |r| r.kind_of?(PythonDependency) }
# So if there is no PythonDependency requirement, we can check if the
# formula still uses python and should add a `depends_on :python`
unless f.name.to_s =~ /(pypy[0-9]*)|(python[0-9]*)/
if text =~ /system.["' ]?python([0-9"'])?/
problem "If the formula uses Python, it should declare so by `depends_on :python#{$1}`"
end
end
end
# Todo:
# The python do ... end block is possibly executed twice. Once for
# python 2.x and once for 3.x. So if a `system 'make'` is called, a
# `system 'make clean'` should also be called at the end of the block.
end
def audit_check_output warning_and_description def audit_check_output warning_and_description
return unless warning_and_description return unless warning_and_description
warning, description = *warning_and_description warning, description = *warning_and_description
@ -572,7 +505,6 @@ class FormulaAuditor
audit_patches audit_patches
audit_text audit_text
text.each_line { |line| audit_line(line) } text.each_line { |line| audit_line(line) }
audit_python
audit_installed audit_installed
end end