Skip to content

Commit

Permalink
refactor: remove pipx configuration and integrate uv tool installatio…
Browse files Browse the repository at this point in the history
…n in scripts
  • Loading branch information
BrightXiaoHan committed Nov 9, 2024
1 parent 5adc2de commit 6f97429
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
4 changes: 0 additions & 4 deletions general/fish/config-linux.fish
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ alias tmux="$INSTALL_DIR/miniconda/bin/tmux"
# Mamba
set -gx MAMBA_ROOT_PREFIX $INSTALL_DIR/miniconda

# pipx
set -gx PIPX_HOME $INSTALL_DIR/pipx
set -gx PIPX_BIN_DIR $INSTALL_DIR/bin

set -gx CPPFLAGS "-I$CONDA_PREFIX/include " $CPPFLAGS
set -gx LDFLAGS "-L$CONDA_PREFIX/lib " $LDFLAGS
set -gx CONFIGURE_OPTS "-with-openssl=$CONDA_PREFIX " $CONFIGURE_OPTS
Expand Down
6 changes: 6 additions & 0 deletions general/fish/config.fish
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ set -gx CRYPTOGRAPHY_OPENSSL_NO_LEGACY 1
# NodeJS
set -gx PATH node_modules/.bin $PATH

# uv
set -gx UV_TOOL_DIR $INSTALL_DIR/uv/tool
set -gx UV_TOOL_BIN_DIR $INSTALL_DIR/uv/tool/bin
set -gx UV_PYTHON_INSTALL_DIR $INSTALL_DIR/uv/python
set -gx UV_PYTHON_PREFERENCE only-managed

# proxy alias
alias setproxy="set ALL_PROXY 'socks5://127.0.0.1:1080'"
alias unsetproxy="set -e ALL_PROXY"
Expand Down
37 changes: 26 additions & 11 deletions homecli/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def install_mamba(overwrite=True):
bin_file,
)
os.chmod(bin_file, 0o755)
logging.info("Installing aliyunpan done.")
logging.info("Installing micromamba done.")


def install_conda():
Expand All @@ -124,27 +124,21 @@ def install_conda():
"-c",
"conda-forge",
"-y",
"python=3.11",
"conda",
"fish",
"ncurses",
"fzf",
"ripgrep",
"make",
"ninja",
"cmake",
"git",
"git-lfs",
"conda-pack",
"poetry",
"tmux",
"libcurl",
"pipx",
"uv",
"ruff",
"compilers",
"zlib",
"nodejs",
"gh",
"jq",
"zoxide",
"starship",
Expand Down Expand Up @@ -178,16 +172,37 @@ def install_conda():
)

env = os.environ.copy()
env["PIPX_HOME"] = os.path.join(CACHE_DIR, "pipx")
env["PIPX_BIN_DIR"] = os.path.join(CACHE_DIR, "bin")
env["UV_TOOL_DIR"] = os.path.join(CACHE_DIR, "uv", "tool")
env["UV_TOOL_BIN_DIR"] = os.path.join(CACHE_DIR, "bin")
env["UV_PYTHON_INSTALL_DIR"] = os.path.join(CACHE_DIR, "uv", "python")

# install python
subprocess.run(
[
os.path.join(CACHE_DIR, "miniconda", "bin", "uv"),
"python",
"install",
"3.12",
],
check=True,
env=env,
)

for package in [
"git+https://github.com/BrightXiaoHan/ssr-command-client.git@master",
"conda-pack",
"poetry",
"gh",
"ruff",
]:
subprocess.run(
[
os.path.join(CACHE_DIR, "miniconda", "bin", "pipx"),
os.path.join(CACHE_DIR, "miniconda", "bin", "uv"),
"tool",
"install",
"--force",
"--python-preference",
"only-managed",
package,
],
check=True,
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ln -sf $DIR/mambarc ~/.mambarc

brew install --quiet \
git-lfs tmux fish neovim ripgrep fzf node aliyunpan trzsz-ssh \
cmake poetry pipx starship zoxide openssh \
cmake poetry starship zoxide openssh \
openssl readline sqlite3 xz zlib gh gnu-sed uv

# install font
Expand Down
4 changes: 2 additions & 2 deletions scripts/pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if [ -n "$1" ]; then
fi
source $INSTALL_DIR/miniconda/bin/activate
rm -f $INSTALL_DIR/miniconda.tar.gz
$INSTALL_DIR/miniconda/bin/conda-pack -o $INSTALL_DIR/miniconda.tar.gz
$INSTALL_DIR/bin/conda-pack -p $INSTALL_DIR/miniconda -o $INSTALL_DIR/miniconda.tar.gz

CURDIR=$(pwd)
echo $CURDIR
Expand All @@ -56,7 +56,7 @@ cd $INSTALL_DIR
rm -rf $INSTALL_DIR/packed
mkdir $INSTALL_DIR/packed
tar --exclude="__pycache__" -cvf $INSTALL_DIR/packed/homecli.tar.gz \
HOME bin miniconda.tar.gz pipx nvim
HOME bin miniconda.tar.gz uv nvim
rm miniconda.tar.gz
cp $INSTALL_DIR/HOME/scripts/install.sh \
$INSTALL_DIR/HOME/scripts/uninstall.sh \
Expand Down

0 comments on commit 6f97429

Please sign in to comment.