Azus

Never be a sad song with nothing to say.

0%

Homebrew

Homebrew 🍺

在安装OpenCV过程中需要不同版本的python,这个时候了解了homebrew的相关技术,觉得unix文件系统管理相当的有意思。但是没有深挖,觉得是一个很大的技术黑盒,在这里站一个坑,以后来填。

首先, brew 本身是酿造、酿酒的意思,会用这个字的原因是 homebrew 的安装方式为下载 source code 回来做编译,由于是在自己电脑做 local compile 编译套件,所以这个工具叫做 homebrew 自家酿酒。
酿酒需要有配方 formula,当你需要安装套件时,流程就是下 brew 命令去根据配方 formula, 酿造出一桶( keg)酒来。所以 keg 指的是整个编译完成的套件资料夹。
再来,放置套件的位置在 /usr/local/Cellar/, Cellar 就是地窖,一桶一桶酿好的酒当然要存放在地窖里囖!所以编译安成的套件资料夹 keg 预设目录在 /usr/local/Cellar/。
最后回到「keg-only」整个词,字面上意思现在就很清除,表示这个套件只会存放在桶子里,不会跑出桶子外。实际上的行为是 brew 不会帮你做 symlink 到 /usr/local,避免你的原生系统内还有一套 readline 而打架,所以提示消息说 readline 套件是 keg-only。
至此,希望你通过上面的解释了解 Homebrew 相关有趣的命名~

Homebrew来源原理

Homebrew 重安装Python@3.8提示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
You can install Python packages with
/opt/homebrew/opt/python@3.8/bin/pip3 install <package>
They will install into the site-package directory
/opt/homebrew/lib/python3.8/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

python@3.8 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have python@3.8 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/python@3.8/bin:$PATH"' >> ~/.zshrc

For compilers to find python@3.8 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/python@3.8/lib"

For pkg-config to find python@3.8 you may need to set:
export PKG_CONFIG_PATH="/opt/homebrew/opt/python@3.8/lib/pkgconfig"

Python@3.8 found in /opt/homebrew/opt/python@3.8/bin/
python@3.9 found in /usr/local/bin/