add upgrade pyvenv scripts
This commit is contained in:
parent
aaff46632c
commit
497723afe1
84
upgrade_pyvenv.sh
Executable file
84
upgrade_pyvenv.sh
Executable file
@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
check_arguments() {
|
||||||
|
[[ -f "$1" ]] && return
|
||||||
|
|
||||||
|
echo "Missing configuration file argument ($1)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
check_venv_path() {
|
||||||
|
[[ -n "$VENV_PATH" ]] && \
|
||||||
|
[[ -d "$VENV_PATH" ]] && \
|
||||||
|
[[ -f "$VENV_PATH/bin/python" ]] && \
|
||||||
|
return;
|
||||||
|
|
||||||
|
echo "$VENV_PATH is not a virtual environment"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
check_requirements_file() {
|
||||||
|
[[ -n "$REQUIREMENTS_FILE" ]] && \
|
||||||
|
[[ -f "$REQUIREMENTS_FILE" ]] && \
|
||||||
|
return;
|
||||||
|
|
||||||
|
echo "$REQUIREMENTS_FILE does not exist"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
check_repo_path() {
|
||||||
|
[[ -n "$REPO_PATH" ]] && \
|
||||||
|
[[ -d "$REPO_PATH" ]] && \
|
||||||
|
(cd $REPO_PATH && git status) && return;
|
||||||
|
|
||||||
|
echo "$REPO_PATH is not a git repository"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
check_arguments $1
|
||||||
|
|
||||||
|
source $1
|
||||||
|
echo "Upgrading virtual environment for `basename $1`"
|
||||||
|
|
||||||
|
check_venv_path
|
||||||
|
|
||||||
|
check_requirements_file
|
||||||
|
|
||||||
|
check_repo_path
|
||||||
|
|
||||||
|
PIP_PATH=$VENV_PATH/bin/pip
|
||||||
|
|
||||||
|
reset_venv() {
|
||||||
|
rm -r $VENV_PATH
|
||||||
|
python3 -m venv $VENV_PATH
|
||||||
|
}
|
||||||
|
|
||||||
|
update_repo() {
|
||||||
|
cd $REPO_PATH
|
||||||
|
git fetch
|
||||||
|
if [[ `git log HEAD..origin | wc -l` == 0 ]];
|
||||||
|
then
|
||||||
|
echo "No changes in current branch of repository"
|
||||||
|
else
|
||||||
|
echo "Changes done in current branch:\n"
|
||||||
|
git log HEAD..origin
|
||||||
|
echo "\nPull new changes? (y/n)"
|
||||||
|
read pull_changes
|
||||||
|
[[ "$pull_changes" == "y" ]] && git pull
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_requirements() {
|
||||||
|
$PIP_PATH install -r $REQUIREMENTS_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Resetting venv..."
|
||||||
|
reset_venv
|
||||||
|
|
||||||
|
update_repo
|
||||||
|
|
||||||
|
echo "Installing requirements..."
|
||||||
|
install_requirements > /dev/null
|
||||||
|
|
||||||
|
echo "Done."
|
||||||
9
upgrade_pyvenv_projects.sh
Executable file
9
upgrade_pyvenv_projects.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
CONF_DIR=/home/emixam/.config/pyvenv_projects.d
|
||||||
|
|
||||||
|
for conf_file in $CONF_DIR/*;
|
||||||
|
do
|
||||||
|
upgrade_pyvenv.sh $conf_file;
|
||||||
|
done;
|
||||||
Loading…
Reference in New Issue
Block a user