[TIP] testing setuptools-related code

Carl Meyer carl at oddbird.net
Thu Jan 19 07:49:47 PST 2012


-----BEGIN PGP SIGNED MESSAGE-----
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.

Carl
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8YO5sACgkQ8W4rlRKtE2ey5QCg3//SjGcXrFJnsseryZHL5SY/
imwAmwa2KeyUffju0CH9OP/Pa2CMuoOo
=2SEP
-----END PGP SIGNATURE-----



More information about the testing-in-python mailing list