utils/pypi: don't require pipgrip unless we are using it

This commit is contained in:
Bo Anderson 2020-07-31 16:56:21 +01:00
parent acd5e58363
commit 92cee70cbd

View File

@ -27,9 +27,6 @@ module PyPI
def update_python_resources!(formula, version = nil, print_only: false, silent: false, def update_python_resources!(formula, version = nil, print_only: false, silent: false,
ignore_non_pypi_packages: false) ignore_non_pypi_packages: false)
@pipgrip_installed ||= Formula["pipgrip"].any_version_installed?
odie '"pipgrip" must be installed (`brew install pipgrip`)' unless @pipgrip_installed
# PyPI package name isn't always the same as the formula name. Try to infer from the URL. # PyPI package name isn't always the same as the formula name. Try to infer from the URL.
pypi_name = if formula.stable.url.start_with?(PYTHONHOSTED_URL_PREFIX) pypi_name = if formula.stable.url.start_with?(PYTHONHOSTED_URL_PREFIX)
File.basename(formula.stable.url).match(/^(.+)-[a-z\d.]+$/)[1] File.basename(formula.stable.url).match(/^(.+)-[a-z\d.]+$/)[1]
@ -52,6 +49,9 @@ module PyPI
odie "\"#{formula.name}\" contains non-PyPI resources. Please update the resources manually." odie "\"#{formula.name}\" contains non-PyPI resources. Please update the resources manually."
end end
@pipgrip_installed ||= Formula["pipgrip"].any_version_installed?
odie '"pipgrip" must be installed (`brew install pipgrip`)' unless @pipgrip_installed
ohai "Retrieving PyPI dependencies for \"#{pypi_name}==#{version}\"" if !print_only && !silent ohai "Retrieving PyPI dependencies for \"#{pypi_name}==#{version}\"" if !print_only && !silent
pipgrip_output = Utils.popen_read Formula["pipgrip"].bin/"pipgrip", "--json", "#{pypi_name}==#{version}" pipgrip_output = Utils.popen_read Formula["pipgrip"].bin/"pipgrip", "--json", "#{pypi_name}==#{version}"
unless $CHILD_STATUS.success? unless $CHILD_STATUS.success?