stratis
stratis

Reputation: 8042

How exactly virtualenvwrapper 'binds' to project directories

Over the past couple of days I started using the excellent virtualenvwrapper by Doug Hellmann and while its feautures are mostly amazing I am struggling to make sense out of a couple of its commands.

setvirtualenvproject states that:

The arguments to setvirtualenvproject are the full paths to the virtualenv and project directory. An association is made so that when workon activates the virtualenv the project is also activated.

What exactly does the author mean here when he says that the project is also activated? I can understand what 'activating a virtual environment' means but 'activating a project' doesn't make much sense to me.

Furthermore, what is this 'binding' that's stated in both

Apperently I am a bit confused over these concepts. Any insight would be highly appreciated. Thanks in advance.

Upvotes: 1

Views: 803

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599590

One of the nice features about virtualenvwrapper is that it can separate your project directory from the virtualenv itself. The project dir contains your code only; the virtualenv contains Python and any third-party libraries. This makes for a much cleaner environment and easier-to-navigate project structure.

Binding a virtualenv to a project is just a matter of a hidden .project file in the virtualenv dir that points to the actual project dir. That means that when you do workon myproject in a project-enabled virtualenv, you are taken there, rather than the virtualenv itself.

Upvotes: 4

Related Questions