Hanna Arhipova | 16e93fb | 2019-01-23 19:03:01 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # This file used as an interface for automatic activating of virtualenv. |
| 4 | # Should be placed into PATH |
| 5 | # Example: with_venv.sh python --version |
| 6 | |
| 7 | set -xe |
| 8 | |
| 9 | function _info(){ |
| 10 | set +x |
| 11 | echo -e "===== virtualenv info: =====" |
| 12 | python --version |
| 13 | pip freeze | sort |
| 14 | echo -e "============================" |
| 15 | set -x |
| 16 | } |
| 17 | |
| 18 | function activate_venv(){ |
| 19 | set +x |
| 20 | if [ -f venv/bin/activate ]; then |
| 21 | echo "Activating venv in $(pwd)" |
| 22 | source venv/bin/activate && echo "Activated succesfully" |
| 23 | else |
| 24 | echo "WARNING: No venv found in $(pwd)" |
| 25 | return 1 |
| 26 | fi |
| 27 | set -x |
| 28 | } |
| 29 | |
| 30 | activate_venv && |
| 31 | _info && |
| 32 | exec "$@" |