Where is virtualenv's deactivate defined?

1

Virtualenv defines an alias for the command deactivate as seen in yourvirtualenv/bin/activate.csh. What I'm curious about is where deactivate resides, because when I issue an alias command deactivate does not appear in the list of active aliases.

Parham

Posted 2013-10-23T09:09:42.293

Reputation: 113

Answers

2

Assuming that you're actually running bash rather than csh, the script you want to look at is yourvirtualenv/bin/activate (not yourvirtualenv/bin/activate.csh), which defines a function called deactivate, not an alias. You can see this with the type command:

$ type deactivate
deactivate is a function
deactivate () 
{ 
    typeset env_postdeactivate_hook;
    typeset old_env;
    virtualenvwrapper_run_hook "pre_deactivate";
    env_postdeactivate_hook="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate";
    old_env=$(basename "$VIRTUAL_ENV");
    virtualenv_deactivate $1;
    virtualenvwrapper_run_hook "post_deactivate" "$old_env";
    if [ ! "$1" = "nondestructive" ]; then
        unset -f virtualenv_deactivate > /dev/null 2>&1;
        unset -f deactivate > /dev/null 2>&1;
    fi
}

user173718

Posted 2013-10-23T09:09:42.293

Reputation:

I saw the function definition as well, but did not know how it related to the alias in the .csh file. Thanks a lot! Had no idea that you could define functions in this manner, as well as type out their definitions. – Parham – 2013-10-24T15:42:47.957