mirror of
https://github.com/Rikj000/MoniGoMani.git
synced 2022-03-06 00:08:05 +03:00
✨ Added pyenv & pipenv support + set shell alias
This commit is contained in:
4
Pipfile
4
Pipfile
@@ -1,5 +1,9 @@
|
||||
[requires]
|
||||
python_version = "3.9"
|
||||
|
||||
[packages]
|
||||
art = "==5.3"
|
||||
cached-property = "==1.5.2"
|
||||
coloredlogs = "==15.0.1"
|
||||
cryptography = "==36.0.0"
|
||||
discord-webhook = "==0.14.0"
|
||||
|
||||
1089
Pipfile.lock
generated
1089
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
91
installer.sh
91
installer.sh
@@ -22,10 +22,15 @@
|
||||
# /usr/bin/env sh <(curl -s "https://raw.githubusercontent.com/Rikj000/MoniGoMani/development/installer.sh")
|
||||
#
|
||||
# === Settings =========================================================================================================
|
||||
INSTALL_FOLDER_NAME="freqtrade-mgm" # By default the folder will be created under the current working directory
|
||||
INSTALL_FOLDER_NAME="Freqtrade-MGM" # By default the folder will be created under the current working directory
|
||||
MGM_REPO_URL="https://github.com/Rikj000/MoniGoMani.git"
|
||||
MGM_BRANCH="development"
|
||||
MGM_COMMIT=""
|
||||
SHELL_CONFIGS=(
|
||||
~/.bashrc
|
||||
~/.config/fish/config.fish
|
||||
~/.zshrc
|
||||
)
|
||||
# ======================================================================================================================
|
||||
|
||||
usage() {
|
||||
@@ -71,6 +76,7 @@ YELLOW='\033[1;33m'
|
||||
|
||||
NOCOLOR='\033[0m'
|
||||
UNDERLINE='\033[4m'
|
||||
ITALIC="\e[3m"
|
||||
BOLD='\033[1m'
|
||||
END='\033[m'
|
||||
|
||||
@@ -198,13 +204,21 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
echo -e "${GREEN} ✅ Pip3 is installed.${END}"
|
||||
|
||||
# Ensure that pyenv is installed
|
||||
command -v pyenv >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED} 🙉 Pyenv is not installed. Can't proceed. See: https://github.com/pyenv/pyenv-installer#pyenv-installer/${END}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN} ✅ Pyenv is installed.${END}"
|
||||
|
||||
# Ensure that python3-venv is installed
|
||||
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||
if [ "$OS" == "\"Ubuntu\"" -o "$OS" == "\"Debian\"" ]; then
|
||||
VENV_PACKAGE_NAME="`readlink -f $(which python3) | awk -F'/' '{print $NF}'`-venv"
|
||||
dpkg -s $VENV_PACKAGE_NAME | grep "ok installed" >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED} 🙉 Python3-venv is not installed. Can't proceed. install it with: sudo apt-get install ${VENV_PACKAGE_NAME}${END}"
|
||||
echo -e "${RED} 🙉 Python3-venv is not installed. Can't proceed. install it with: sudo apt install ${VENV_PACKAGE_NAME}${END}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN} ✅ Python3-venv is installed.${END}"
|
||||
@@ -272,23 +286,78 @@ else
|
||||
fi
|
||||
|
||||
if [ "$DEV_BREAK" == "true" ]; then
|
||||
echo ""
|
||||
confirm "👉 Are you ready to proceed?" "(y/n)"
|
||||
echo ""
|
||||
confirm "👉 Are you ready to proceed?" "(y/n)"
|
||||
|
||||
if [ "$REPLY" == "1" ] # 1 = False, why shell why..
|
||||
then
|
||||
do_exit
|
||||
exit 1
|
||||
fi
|
||||
if [ "$REPLY" == "1" ] # 1 = False, why shell why..
|
||||
then
|
||||
do_exit
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
|
||||
echo -e "${WHITE} ⚙️ Installing dependency packages...${END}"
|
||||
echo -e "${WHITE} ⚙️ Installing pipenv...${END}"
|
||||
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
|
||||
echo ""
|
||||
echo -e "${ITALIC}(Some errors which are usually safe to ignore might occur during the installation of pip & pipenv)${END}"
|
||||
echo ""
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
|
||||
if [ "$OS" == "\"Ubuntu\"" ]; then
|
||||
sudo apt install -y libffi-dev
|
||||
fi
|
||||
|
||||
cd "$INSTALL_DIR" && python3 -m pip install pipenv
|
||||
|
||||
echo ""
|
||||
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
|
||||
echo -e "${WHITE} ⚙️ Setting up virtual environment with python dependency packages...${END}"
|
||||
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
|
||||
echo ""
|
||||
|
||||
cd "$INSTALL_DIR" && pip3 install -r ./monigomani/requirements-mgm.txt && python3 ./monigomani/mgm-hurry up
|
||||
cp "$INSTALL_DIR/monigomani/Pipfile" "$INSTALL_DIR/" # && cp "$INSTALL_DIR/monigomani/Pipfile.lock" "$INSTALL_DIR/"
|
||||
cd "$INSTALL_DIR" && python3 -m pipenv install
|
||||
|
||||
echo ""
|
||||
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
|
||||
echo -e "${WHITE} ⚙️ Proceeding to Freqtrade & MoniGoMani installation...${END}"
|
||||
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
|
||||
echo ""
|
||||
|
||||
cd "$INSTALL_DIR" && python3 -m pipenv run python3 "$INSTALL_DIR"/monigomani/mgm-hurry up
|
||||
|
||||
echo ""
|
||||
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
|
||||
echo -e "${WHITE} ⚙️ Setting up shell alias...${END}"
|
||||
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
|
||||
echo ""
|
||||
|
||||
echo "You can now run MGM-hurry commands with: 'python3 -m pipenv run python3 ./mgm-hurry ...' only from inside: $INSTALL_DIR"
|
||||
echo ""
|
||||
confirm "👉 Do you want to add a shell alias so you can run MGM-hurry commands more easily from all over your system as 'mgm-hurry ...'?" "(y/n)"
|
||||
|
||||
if [ "$REPLY" == "0" ] # 1 = False, why shell why..
|
||||
then
|
||||
for SHELL_CONFIG in "${SHELL_CONFIGS[@]}"; do
|
||||
# Make sure all Shell config files exist
|
||||
touch "$SHELL_CONFIG"
|
||||
if [ "$SHELL_CONFIG" != ~/.config/fish/config.fish ]; then
|
||||
echo "" >> "$SHELL_CONFIG"
|
||||
echo "# MGM-Hurry shell alias" >> "$SHELL_CONFIG"
|
||||
echo "mgm-hurry() { pushd "$INSTALL_DIR" &> /dev/null; python3 -m pipenv run python3 ./mgm-hurry "\$@"; popd &> /dev/null; }" >> "$SHELL_CONFIG"
|
||||
else
|
||||
FISH_FUNCTION=~/.config/fish/functions/mgm-hurry.fish
|
||||
mkdir -p ~/.config/fish/functions/; touch "$FISH_FUNCTION";
|
||||
echo "function mgm-hurry" >> "$FISH_FUNCTION"
|
||||
echo "pushd "$INSTALL_DIR" &> /dev/null; python3 -m pipenv run python3 ./mgm-hurry \$argv; popd &> /dev/null;" >> "$FISH_FUNCTION"
|
||||
echo "end" >> "$FISH_FUNCTION"
|
||||
fi
|
||||
done
|
||||
echo -e "${CYAN}🎉 Shell aliases have been set! Please close & re-open your terminal for the aliases to become active!"${END}
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
@@ -237,10 +237,13 @@ class FreqtradeCli:
|
||||
if os.path.isfile(f'{target_dir}/setup.exp'):
|
||||
command = f'expect {target_dir}/setup.exp'
|
||||
if distro.id() in ['ubuntu', 'debian']:
|
||||
command = f'sudo {command}'
|
||||
command = f'echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USER-temp-root; ' \
|
||||
f'{command}; sudo rm /etc/sudoers.d/$USER-temp-root'
|
||||
|
||||
# Using 'except' to automatically skip resetting the git repo, but do install all dependencies
|
||||
self.monigomani_cli.run_command(command)
|
||||
# Temporarily unset the VIRTUAL_ENV environment variable to keep Freqtrade from aborting the installation
|
||||
self.monigomani_cli.run_command(f'export VIRTUAL_ENV_BAK=$VIRTUAL_ENV; unset VIRTUAL_ENV; {command}; '
|
||||
f'export VIRTUAL_ENV=$VIRTUAL_ENV_BAK; unset VIRTUAL_ENV_BAK;')
|
||||
if install_ui is True:
|
||||
# Explicitly re-fetch the Freqtrade binary path after installation
|
||||
self.freqtrade_binary = self._get_freqtrade_binary_path(self.basedir, self.install_type)
|
||||
|
||||
@@ -177,6 +177,9 @@ class MoniGoManiCli(object):
|
||||
if os.path.isfile(f'{target_dir}/{delete_file}'):
|
||||
os.remove(f'{target_dir}/{delete_file}')
|
||||
|
||||
for pip_file in ['Pipfile', 'Pipfile.lock']:
|
||||
copy2(f'{target_dir + mgm_folder}/{pip_file}', f'{target_dir}/{pip_file}')
|
||||
|
||||
# Symlink separate files and whole directories
|
||||
symlink_objects = {
|
||||
'Documentation',
|
||||
|
||||
Reference in New Issue
Block a user