fix cmd and sh script with Miniforge3

This commit is contained in:
workmin
2025-02-22 06:34:11 -08:00
parent cf75feb22f
commit b3e5f8de13
2 changed files with 18 additions and 7 deletions

11
app.py
View File

@@ -51,9 +51,15 @@ def check_and_install_requirements(file_path):
print(error)
return False
try:
import regex as re
from importlib.metadata import version, PackageNotFoundError
from tqdm import tqdm
try:
import regex as re
from tqdm import tqdm
except Exception as e:
subprocess.check_call([sys.executable, '-m', 'pip', 'cache', 'purge'])
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'regex', 'tqdm'])
import regex as re
from tqdm import tqdm
with open(file_path, 'r') as f:
contents = f.read().replace('\r', '\n')
packages = [pkg.strip() for pkg in contents.splitlines() if pkg.strip()]
@@ -71,7 +77,6 @@ def check_and_install_requirements(file_path):
msg = '\nInstalling missing packages...\n'
print(msg)
os.environ['TMPDIR'] = tmp_dir
subprocess.check_call([sys.executable, '-m', 'pip', 'cache', 'purge'])
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip'])
with tqdm(total=len(packages), desc='Installation 0.00%', bar_format='{desc}: {n_fmt}/{total_fmt} ', unit='step') as t:
for package in tqdm(missing_packages, desc="Installing", unit="pkg"):

View File

@@ -255,8 +255,14 @@ else
}
function conda_check {
if ! command -v conda &> /dev/null; then
echo -e "\e[33mMiniforge3 is not installed!\e[0m"
if ! command -v conda &> /dev/null || [ ! -f "$CONDA_ENV" ]; then
if [ -d $HOME/miniconda3 ]; then
echo "Miniconda3 is deprecated, switching to Miniforge3..."
$HOME/miniconda3/bin/conda deactivate
rm -rf $HOME/miniconda3
else
echo -e "\e[33mMiniforge3 is not installed!\e[0m"
fi
echo -e "\e[33mDownloading Miniforge3 installer...\e[0m"
if [[ "$OSTYPE" = "darwin"* ]]; then
curl -fsSLo "$CONDA_INSTALLER" "$CONDA_URL"
@@ -265,10 +271,10 @@ else
fi
if [[ -f "$CONDA_INSTALLER" ]]; then
echo -e "\e[33mInstalling Miniforge3...\e[0m"
bash "$CONDA_INSTALLER" -b -p "$CONDA_INSTALL_DIR"
bash "$CONDA_INSTALLER" -b -u -p "$CONDA_INSTALL_DIR"
rm -f "$CONDA_INSTALLER"
if [[ -f "$CONDA_INSTALL_DIR/bin/conda" ]]; then
conda config --set auto_activate_base false
$CONDA_INSTALL_DIR/bin/conda config --set auto_activate_base false
source $CONDA_ENV
echo -e "\e[32m===============>>> conda is installed! <<===============\e[0m"
else