如何在Homebrew中手动保存缓存文件?

huangapple go评论79阅读模式
英文:

How to manual save a cache file in Homebrew?

问题

在受限网络环境中,您想要使用Homebrew和代理安装python@3.11,但代理无法下载某些依赖项。您可以手动从源中下载某些依赖项,但如何保存到缓存呢?似乎需要遵循一些命名约定,例如:

  • 2322057182c6bb73dfe09e098010168a5a9d0712a89cee86d2c5ddb11052137e--3.11-sysconfig.diff
  • 5fea40db1cb33001d6ab42c76fc28693ce292532c6ed6f89dd3154dac29167bb--3.10-distutils-scheme.diff

而不仅仅是flit_core-3.8.0.tar.gz,因为保存为该名称时仍然尝试从互联网下载。您的问题是如何指定手动下载的依赖项,或者保存它们时的命名约定是什么?感谢您的提前回答。

英文:

I am in a restricted network environment and wanted to install python@3.11 with homebrew using brew install python@3.11 with a proxy, the proxy allowed me to download some files but not all. Some dependencies it fails to download due to the proxy, however I can manual download from the source in other methods, but how can I save to the cache? It seems need to follow some naming convention e.g.

  • 2322057182c6bb73dfe09e098010168a5a9d0712a89cee86d2c5ddb11052137e--3.11-sysconfig.diff
  • 5fea40db1cb33001d6ab42c76fc28693ce292532c6ed6f89dd3154dac29167bb--3.10-distutils-scheme.diff

But not just flit_core-3.8.0.tar.gz because when I save it as it still trying to download from internet. My questions is how do I specify the manual downloaded dependency? Or what's the naming convention when saving it? Thanks in advance.

brew install python@3.11
Running brew update --auto-update...
==> Fetching python@3.11
Warning: Building python@3.11 from source as the bottle needs:
HOMEBREW_CELLAR: /opt/homebrew/Cellar (yours is /Users/zhangtai/.brew/Cellar)
HOMEBREW_PREFIX: /opt/homebrew (yours is /Users/zhangtai/.brew)
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/6d2fba8de3159182025237d373a6f4f78b8bd203/python/3.11-sysconfig.diff
Already downloaded: /Users/zhangtai/Library/Caches/Homebrew/downloads/2322057182c6bb73dfe09e098010168a5a9d0712a89cee86d2c5ddb11052137e--3.11-sysconfig.diff
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/a1618a5005d0b01d63b720321806820a03432f1a/python/3.10-distutils-scheme.diff
Already downloaded: /Users/zhangtai/Library/Caches/Homebrew/downloads/5fea40db1cb33001d6ab42c76fc28693ce292532c6ed6f89dd3154dac29167bb--3.10-distutils-scheme.diff
Error: python@3.11: Failed to download resource "python@3.11--flit-core"
Failure while executing; /usr/bin/env /Users/zhangtai/.brew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.13\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.3\)\ curl/7.87.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head --request GET https://files.pythonhosted.org/packages/10/e5/be08751d07b30889af130cec20955c987a74380a10058e6e8856e4010afc/flit_core-3.8.0.tar.gz exited with 22. Here's the output:
HTTP/1.1 200 Connection established
HTTP/1.1 403 Forbidden
Cache-Control: no-cache
Pragma: no-cache
X-XSS-Protection: 1
Content-Type: text/html; charset=utf-8
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Content-Length: 3444
curl: (22) The requested URL returned error: 403

答案1

得分: 0

只需编辑 python@3.11.rb 文件并将 URL 更改为本地文件,然后重新安装

nano /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.11.rb

找到 "sysconfig.diff" 部分

    url "https://raw.githubusercontent.com/Homebrew/formula-patches/6d2fba8de3159182025237d373a6f4f78b8bd203/python/3.11-sysconfig.diff"

更改为

    url "file:///Users/c/Downloads/3.11-sysconfig.diff"

保存并重新安装 python.

英文:

just edit python@3.11.rb file and change url to the local file, and reinstall

nano /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.11.rb

find "sysconfig.diff" part

    url "https://raw.githubusercontent.com/Homebrew/formula-patches/6d2fba8de3159182025237d373a6f4f78b8bd203/python/3.11-sysconfig.diff"

change to

    url "file:///Users/c/Downloads/3.11-sysconfig.diff"

save and reinstall python.

答案2

得分: 0

I found the answer.

    url_sha256 = Digest::SHA256.hexdigest(url)
    downloads = Pathname.glob(HOMEBREW_CACHE/"downloads/#{url_sha256}--*")

Open irb in the terminal and run below to get the hash, rename the file accordingly, fixed it.

require 'digest'
Digest::SHA256.hexdigest("https://files.pythonhosted.org/packages/10/e5/be08751d07b30889af130cec20955c987a74380a10058e6e8856e4010afc/flit_core-3.8.0.tar.gz")

p.s. run brew edit python@3.11 to get the dependencies urls.

英文:

After search the source code for keywords "downloads", I found the answer.

    url_sha256 = Digest::SHA256.hexdigest(url)
    downloads = Pathname.glob(HOMEBREW_CACHE/"downloads/#{url_sha256}--*")

Open irb in the terminal and run below to get the hash, rename the file accordingly, fixed it.

require 'digest'
Digest::SHA256.hexdigest("https://files.pythonhosted.org/packages/10/e5/be08751d07b30889af130cec20955c987a74380a10058e6e8856e4010afc/flit_core-3.8.0.tar.gz")

p.s. run brew edit python@3.11 to get the dependencies urls.

huangapple
  • 本文由 发表于 2023年4月13日 18:33:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76004416.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定