#!/bin/bash OPEN_PROJECT_NAME="isort" if [ "$PROJECT_NAME" = "$OPEN_PROJECT_NAME" ]; then return fi if [ ! -f ".env" ]; then return fi export PROJECT_NAME=$OPEN_PROJECT_NAME export PROJECT_DIR="$PWD" if [ ! -d "venv" ]; then if ! hash pyvenv 2>/dev/null; then function pyvenv() { if hash pyvenv-3.5 2>/dev/null; then pyvenv-3.5 $@ fi if hash pyvenv-3.4 2>/dev/null; then pyvenv-3.4 $@ fi if hash pyvenv-3.3 2>/dev/null; then pyvenv-3.3 $@ fi if hash pyvenv-3.2 2>/dev/null; then pyvenv-3.2 $@ fi } fi echo "Making venv for $PROJECT_NAME" pyvenv venv . venv/bin/activate python setup.py install pip install -r requirements.txt fi . venv/bin/activate # Let's make sure this is a hubflow enabled repo yes | git hf init >/dev/null 2>/dev/null # Quick directory switching alias root="cd $PROJECT_DIR" alias project="root; cd $PROJECT_NAME" # Commands alias test="root; py.test test_isort.py -s" alias install="_install_project" alias distribute="python setup.py sdist upload; python setup.py bdist_wheel upload" alias leave="_leave_project" function _install_project() { CURRENT_DIRECTORY="$PWD" root sudo python setup.py install cp isort_kate_plugin.py ~/.kde/share/apps/kate/pate/isort_plugin.py >/dev/null 2>/dev/null cd $CURRENT_DIRECTORY } function load { (root python setup.py install) } function interact { (load ipython -c "import isort" -i) } function _leave_project() { export PROJECT_NAME="" export PROJECT_DIR="" unalias root unalias project unalias test unalias install unalias distribute unalias leave unset -f load unset -f interact deactivate }