Merge pull request #8147 from Rylan12/bump-formula-pr-pypi-version
bump-formula-pr: handle pypi url version changes
This commit is contained in:
commit
8e370b35fa
@ -183,6 +183,7 @@ module Homebrew
|
||||
elsif !new_url && !new_version
|
||||
odie "#{formula}: no --url= or --version= argument specified!"
|
||||
else
|
||||
new_url ||= PyPI.update_pypi_url(old_url, new_version)
|
||||
new_url ||= old_url.gsub(old_version, new_version)
|
||||
if new_url == old_url
|
||||
odie <<~EOS
|
||||
|
||||
@ -7,6 +7,20 @@ module PyPI
|
||||
|
||||
@pipgrip_installed = nil
|
||||
|
||||
def url_to_pypi_package_name(url)
|
||||
return unless url.start_with? PYTHONHOSTED_URL_PREFIX
|
||||
|
||||
File.basename(url).match(/^(.+)-[a-z\d.]+$/)[1]
|
||||
end
|
||||
|
||||
def update_pypi_url(url, version)
|
||||
package = url_to_pypi_package_name url
|
||||
return if package.nil?
|
||||
|
||||
_, url = get_pypi_info(package, version)
|
||||
url
|
||||
end
|
||||
|
||||
# Get name, url, and version for a given pypi package
|
||||
def get_pypi_info(package, version)
|
||||
metadata_url = "https://pypi.org/pypi/#{package}/#{version}/json"
|
||||
@ -32,7 +46,7 @@ module PyPI
|
||||
|
||||
# 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)
|
||||
File.basename(formula.stable.url).match(/^(.+)-[a-z\d.]+$/)[1]
|
||||
url_to_pypi_package_name formula.stable.url
|
||||
else
|
||||
formula.name
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user