Skip to content

Commit

Permalink
resource: automatic determine mirrors for PyPI resources
Browse files Browse the repository at this point in the history
  • Loading branch information
XuehaiPan committed Sep 15, 2022
1 parent 46b3d24 commit d3093cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ module EnvConfig
"outdated.",
boolean: true,
},
HOMEBREW_PIP_INDEX_URL: {
description: "If set, `brew install <formula>` will use this URL to download PyPI package resources.",
default_text: "`https://pypi.org/simple`.",
},
HOMEBREW_PRY: {
description: "If set, use Pry for the `brew irb` command.",
boolean: true,
Expand Down
8 changes: 8 additions & 0 deletions Library/Homebrew/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,14 @@ def determine_url_mirrors
end
end

# PyPI packages: PEP 503 – Simple Repository API <https://peps.python.org/pep-0503>
if Homebrew::EnvConfig.pip_index_url.present?
pip_index_base_url = Homebrew::EnvConfig.pip_index_url.chomp("/").chomp("/simple")
%w[https://files.pythonhosted.org https://pypi.org].each do |base_url|
extra_urls << url.sub(base_url, pip_index_base_url) if url.start_with?("#{base_url}/packages")
end
end

[*extra_urls, url, *mirrors].uniq
end

Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/sorbet/rbi/hidden-definitions/hidden.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -2655,6 +2655,8 @@ module Homebrew::EnvConfig

def self.no_proxy(); end

def self.pip_index_url(); end

def self.pry?(); end

def self.simulate_macos_on_linux?(); end
Expand Down

0 comments on commit d3093cd

Please sign in to comment.