Audit LanguageModuleDependency for python

LanguageModuleDependency.new(:python,...) is deprecated now.
Replace it by
    depends_on :python => ['module' => 'name-on-PyPi']
This commit is contained in:
Samuel John 2013-07-16 11:10:14 +02:00
parent fb7f16fc94
commit 8f0a073bf6

View File

@ -496,23 +496,30 @@ class FormulaAuditor
def audit_python
if text =~ /(def\s*)?which_python/
problem "Replace `which_python` by `python.xy`, which returns e.g. 'python2.7'."
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, ...`."
problem "Instead of `system 'python', ...`, call `system python, ...`"
end
if text =~ /system\(?\s*python\.binary/
problem "Instead of `system python.binary, ...`, call `system python, ...`."
problem "Instead of `system python.binary, ...`, call `system python, ...`"
end
end
@ -534,7 +541,7 @@ class FormulaAuditor
# Don't check this for all formulae, because some are allowed to set the
# PYTHONPATH. E.g. python.rb itself needs to set it.
if text =~ /ENV\.append.*PYTHONPATH/ || text =~ /ENV\[['"]PYTHONPATH['"]\]\s*=[^=]/
problem "Don't set the PYTHONPATH, instead declare `depends_on :python`."
problem "Don't set the PYTHONPATH, instead declare `depends_on :python`"
end
else
# So if there is no PythonInstalled requirement, we can check if the