使用homebrew管理linux和mac的包

<~生~信~交~流~与~合~作~请~关~注~公~众~号@生信探索>

添加镜像

linux和apple都一样,先添加变量

export HOMEBREW_INSTALL_FROM_API=1
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"

export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"

Apple M2

  • 安装CLT for Xcode
xcode-select --install
  • 安装brew
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
rm -rf brew-install
  • 加入环境变量
test -r ~/.bash_profile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
test -r ~/.zprofile && echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile

Ubuntu 22.4

需要git 和 curl

无root

  • 安装到~/homebrew
cd ~
mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  • 加入环境变量
mkdir -p ~/APP/bin
export PATH=$HOME/APP/bin:$PATH
ln -s $HOME/homebrew/bin/brew $HOME/APP/bin/brew

有root

  • 安装
git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
/bin/bash brew-install/install.sh
rm -rf brew-install
  • 加入环境变量
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile
test -r ~/.profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile
test -r ~/.zprofile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.zprofile

更新

brew update

Uninstall

-p是homebrew的安装路径,root安装的homebrew有默认路径,不需要卸载的时候指定这个参数

cd ~
wget https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
bash uninstall.sh -p ~/homebrew

安装mamba

  • linux

linux上只能安装micromamba

brew install micromamba
# 手动安装mamba
wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh
bash Mambaforge-Linux-x86_64.sh
  • Apple M2
brew install --cask mambaforge
# 单细胞分析环境
mamba create -n SC && mamba activate SC
mamba install -y -c conda-forge python=3.10 notebook ipywidgets pandas numpy seaborn matplotlib ipykernel openpyxl pyarrow scanpy python-igraph leidenalg pytables jaxlib leidenalg

Reference

https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/
https://docs.brew.sh/Installation#alternative-installs

本文由 mdnice 多平台发布

你可能感兴趣的:(程序人生)