makefilevirtualenvwrapper

deactivate virtualenv on Makefile


I am writing a Makefile and I wanna call the virtualenvwrapper command "deactivate" inside Makefile.

The anwser of this thread How to leave/exit/deactivate a python virtualenv? has a comment saying that "deactivate" command is not a binary, nor a script, it's a dinamyc alias shell created when you activate your virtualenv.

So, how can I do that?


Solution

  • As seen in virtualenvwrapper code, deactivate is a function that is sourced into your env when you use workon.

    I think that, for security reasons, make does not give access inside Makefile to current users functions and alias. So, inside your Makefile, you should source virtualenvwrapper.sh, workon on the virtualenv you want and then you'll have access to your deactivate command.

    Being axe a target you have on your Makefile and brings_axe a virtualenv you already have, you should do something like this:

    axe:
        source virtualenvwrapper.sh; workon brings_axe; deactivate