[TIP] testing setuptools-related code

Andrea Crotti andrea.crotti.0 at gmail.com
Fri Jan 20 06:00:17 PST 2012

On 01/19/2012 03:49 PM, Carl Meyer wrote:
> Hash: SHA1
> Hi Andrea
> On 01/19/2012 07:44 AM, Andrea Crotti wrote:
>> One possible idea (which might come handy also for other purposes) is to
>> use
>> virtualenv, the problem is that I don't find any example where it's
>> actually used from
>> other python scripts, without an actual shell interaction.
>> I think something like this would be good:
>>      virtualenv.create_environment(venv, site_packages=False, clear=False)
>>      e = Egg(path.join('deps', 'app'))
>>      e.develop()
>> But I have to find a way to tell my code to pass to the Popen the
>> virtualenv activation,
>> anyone already did it?
> "Activation" of a virtualenv is a misleading concept - all that matters
> is that the virtualenv's Python binary is executed. So to run a
> subprocess "in" a virtualenv, just execute "venv/bin/python" instead of
> "/usr/bin/python" or whatnot. Or execute any of the other scripts in
> "venv/bin", they should all have shebang lines pointing to the
> virtualenv's Python.
> Virtualenv shell "activation" only does one thing that matters: modifies
> your shell PATH so "venv/bin" is first on it.

Interesting thanks, this might be a solution for the other problem,
instead of using the --multi-version flag I could just create or activate
virtual environments on demand, the only thing is that it would be
nice to make it as transparent as possible to the user, which
might be the only trickly party..

More information about the testing-in-python mailing list