Last active
December 13, 2021 18:30
-
-
Save agowa/b687ac92d7fbf8a6dade43703fff8299 to your computer and use it in GitHub Desktop.
Git python venv and git submodule init script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Place this file in `ci/init.sh` within any Git repository. | |
: <<EOF | |
MIT License | |
Copyright (c) 2021 Klaus Frank | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
EOF | |
set -e | |
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) # The current directory | |
ROOT=$DIR/.. # The root of the project | |
pushd $DIR | |
if [[ ! -f "$ROOT/venv" ]] | |
then | |
source virtualenvwrapper.sh | |
export WORKON_HOME="$ROOT" | |
export python_version="$(cat $ROOT/.python-version)" | |
export VIRTUALENV_PYTHON="$(pyenv root)/versions/$python_version/bin/python" | |
pyenv install -s $python_version | |
mkvirtualenv -r $ROOT/requirements.txt venv | |
#pip install --upgrade -r $ROOT/requirements.txt | |
fi | |
# Git Submodules | |
git lfs install | |
if [[ -z "${GITLAB_CI}" ]] | |
then | |
# Remove unclean git submodule checkouts if any | |
git submodule deinit --all | |
fi | |
# Sync remote paths from .gitmodules | |
git submodule sync --recursive | |
# Initialize submodules to latest remote version (if specified) | |
git submodule update --init --recursive --remote | |
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Place this file in `ci/init.sh` within any Git repository. | |
: <<EOF | |
MIT License | |
Copyright (c) 2021 Klaus Frank | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
EOF | |
set -e | |
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) # The current directory | |
ROOT=$DIR/.. # The root of the project | |
pushd $DIR | |
if [[ ! -f "$ROOT/venv" ]] | |
then | |
virtualenv --activators bash --clear --download $ROOT/venv | |
source $ROOT/venv/bin/activate | |
pip install --upgrade -r $ROOT/requirements.txt | |
fi | |
# Git Submodules | |
git lfs install | |
if [[ -z "${GITLAB_CI}" ]] | |
then | |
# Remove unclean git submodule checkouts if any | |
git submodule deinit --all | |
fi | |
# Sync remote paths from .gitmodules | |
git submodule sync --recursive | |
# Initialize submodules to latest remote version (if specified) | |
git submodule update --init --recursive --remote | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment