user4396386
user4396386

Reputation: 433

Why is `source` used in the .bash_profile with virtualenvwrapper?

virtualenvwrapper instructs us to put source /usr/local/bin/virtualenvwrapper.sh in our .bash_profile. Why?

I see it creates .virtualenvs the first time it's run. Is .virtualenvs newly created every time I $ source .bash_profile? If yes, is this so .virtualenvs can be updated as virtualenvwrapper is updated?

Upvotes: 1

Views: 256

Answers (1)

sobolevn
sobolevn

Reputation: 18080

That's just a helper module to bind your shell and virtualenvwrapper together. It defines such helpers as:

  • workon to activate a virtualenv
  • mkvirtualenv to create new ones
  • rmvirtualenv to delete unused virtualenvs
  • and some other commands, type virtualenvwrapper to see the full list

When you are sourceing something it is pretty much the same as importing in python. And no, it does not create ~/.virtualenvs folder each time.

It also does some preparations: checking that ~/.virtualenvs folder is in place and that hooks are executed properly.

You can always see the source code of this file by running: cat /usr/local/bin/virtualenvwrapper.sh.

Upvotes: 1

Related Questions