From 6f97429a6162a93834e441ce2c43b5ba4bd2807e Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Sat, 9 Nov 2024 16:15:41 +0000 Subject: [PATCH] refactor: remove pipx configuration and integrate uv tool installation in scripts --- general/fish/config-linux.fish | 4 ---- general/fish/config.fish | 6 ++++++ homecli/install.py | 37 ++++++++++++++++++++++++---------- scripts/install_macos.sh | 2 +- scripts/pack.sh | 4 ++-- 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/general/fish/config-linux.fish b/general/fish/config-linux.fish index 468c9c6..9f05004 100644 --- a/general/fish/config-linux.fish +++ b/general/fish/config-linux.fish @@ -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 diff --git a/general/fish/config.fish b/general/fish/config.fish index 5c6d650..7ed3727 100644 --- a/general/fish/config.fish +++ b/general/fish/config.fish @@ -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" diff --git a/homecli/install.py b/homecli/install.py index 7d046c6..74ff14c 100644 --- a/homecli/install.py +++ b/homecli/install.py @@ -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(): @@ -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", @@ -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, diff --git a/scripts/install_macos.sh b/scripts/install_macos.sh index dc2f41e..71b1075 100755 --- a/scripts/install_macos.sh +++ b/scripts/install_macos.sh @@ -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 diff --git a/scripts/pack.sh b/scripts/pack.sh index 599bcdf..17ed4a4 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -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 @@ -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 \