-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resource: try to download from fast mirrors before resource URLs #13868
Conversation
7766f3c
to
44fc08c
Compare
resource.fast_mirror("bar") | ||
resource.fast_mirror("baz") | ||
expect(resource.url).to eq("foo") | ||
expect(resource.downloader.mirrors).to eq(%w[baz foo]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The attribute downloader.url
is private so the corresponding test has not been added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems too niche to add a DSL for.
I suggest finding a way to handle this appropriately when HOMEBREW_*_DOMAIN
variables are set instead without requiring any changes from the formula.
@carlocab No, resource "some-resource-on-slow-ftp-server" do
url "ftp://the-official-ftp.com/resource-tag.tar.gz"
fast_mirror "https://github.com/the-official-mirror/release/tag/resource-tag.tar.gz"
sha256 "..."
end
resource "pypi-resouce" do
url "https://files.pythonhosted.org/packages/xx/xx/xxx...xxx/package-tag.tar.gz"
fast_mirror "https://github.com/author/package/release/tag/package-tag.tar.gz"
sha256 "..."
end We will try to download from the
By now, we only have However, this seems invisible to the user/maintainer of third-party mirror sites (documentation required). Also, if we vendor something in a new repo Also, explicitly having In addition to the PyPI example above, having class Resouce
def url(val = nil, **specs)
return @url if val.nil?
specs = specs.dup
# Don't allow this to be set.
specs.delete(:insecure)
@url = val
@using = specs.delete(:using)
@download_strategy = DownloadStrategyDetector.detect(url, using)
@specs.merge!(specs)
@downloader = nil
@version = detect_version(@version)
+
+ return unless val.start_with?("https://files.pythonhosted.org/packages")
+ return unless Homebrew::EnvConfig.pip_extra_index_url.present?
+
+ filename = val.partition("/").last
+ Homebrew::EnvConfig.pip_extra_index_url.split(",").each do |extra_index_url|
+ fast_mirror "#{extra_index_url.chomp("/")}/#{name}/#{filename}"
+ end
end
def fast_mirror(val)
fast_mirrors << val
end
end in Homebrew/brew.
I don't think it is a big problem, because it does even not requires a revision bump. We do not need to rebottle things. And only the |
I understand, but I don't think we're interested in adding If there is a static URL that is reproducibly faster than the existing one declared by the resource/formula from multiple different locations, then we should consider using that as the
I disagree. I think adding a bunch of extra code to multiple formulae when it's unclear how many and by how much users will benefit, is a gigantic problem. |
Agreed.
Agreed. My suggestion would be just to special-case the https://github.com/Homebrew/glibc-bootstrap/releases. Alternatively, would I fix things if these were just uploaded to GitHub Packages instead/as well? If so, we could consider just doing that. |
I think uploading the bootstrap packages to GitHub Packages and adding them to https://formulae.brew.sh/api/formula.json is the best solution. No changes are required in Homebrew/brew. We Only need to update the URLs in |
We can do this.
We won't do this. How are you handling e.g. portable-ruby: brew/Library/Homebrew/cmd/vendor-install.sh Lines 55 to 56 in 6eaa510
|
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Resolves Homebrew/glibc-bootstrap#6
Support
fast_mirror
semantic inresource
blocks. For example:The word "fast“ means we should try it before
url
. For fast mirrors, we will:${HOMEBREW_BOTTLE_DOMAIN}
and${HOMEBREW_ARTIFACT_DOMAIN}
in the URL to the corresponding environment variables (curly brackets are optional). If the environment variable is not set or set to the default value, the fast mirror will be ignored.url
will treat as a fallback mirror. The priority of the URLs:fast_mirrors
if anyurl
mirrors
if anyCurlDownloadStrategy
will usefast_mirrors
.