From 5ad9e074e16c33a51f46c6099bca69b8ecfbda3a Mon Sep 17 00:00:00 2001 From: Brandon Rodriguez <brodriguez8774@gmail.com> Date: Mon, 14 Nov 2022 19:49:06 -0500 Subject: [PATCH] Add some basic setup for python poetry --- src/initialize_git.sh | 2 +- src/setup_python_for_development.sh | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/initialize_git.sh b/src/initialize_git.sh index fcdfa38..b8a07e9 100755 --- a/src/initialize_git.sh +++ b/src/initialize_git.sh @@ -26,7 +26,7 @@ function main () { # Install git and tk. echo -e "${text_blue}Checking apt for git. This may ask for your system password.${text_reset}" - sudo apt install git gitk + sudo apt install git gitk curl # Set up git email credentials for machine. user_input="" diff --git a/src/setup_python_for_development.sh b/src/setup_python_for_development.sh index 64dc454..7b286b7 100755 --- a/src/setup_python_for_development.sh +++ b/src/setup_python_for_development.sh @@ -72,9 +72,28 @@ function main () { # Install PipEnv. python3 -m pip install --user pipenv > /dev/null - echo "" - echo -e "${text_blue}Python setup complete.${text_reset}" - echo "" + # Setup Poetry (PipEnv alternative). + # Install Poetry. + curl -sSL https://install.python-poetry.org | python3 - + + # Check that .bashrc file exists. + if [[ -f "${bashrc_file}" ]] + then + # Add PipEnv settings to .bashrc file. + path_search_string="PATH=\"\$PATH:/home/${username}/.local/bin\"" + bashrc_contents="$(cat ${bashrc_file})" + + # Check if either value is not present. + if [[ ! "${bashrc_contents}" =~ "${path_search_string}" ]] + then + # Append. + echo "" >> "${bashrc_file}" + echo "" >> "${bashrc_file}" + echo "# Poetry Settings." >> "${bashrc_file}" + echo "${path_search_string}" >> "${bashrc_file}" + + fi + fi # Add updated cd function to .bashrc file. # On cd into folders, this will load any Python environments in the direct folder that match ".env" or ".venv". @@ -103,6 +122,10 @@ function main () { fi fi + + echo "" + echo -e "${text_blue}Python setup complete.${text_reset}" + echo "" } -- GitLab