[Python-ideas] npm-style venv-aware launcher

Carl Meyer carl at oddbird.net
Mon Jun 1 19:58:42 CEST 2015


On 06/01/2015 03:05 AM, M.-A. Lemburg wrote:
> If you want to have a system that doesn't require activation,
> you may want to take a look at what we've done with PyRun:

Virtualenv doesn't require activation either.

Activation is a convenience for running repeated commands in the
virtualenv context, but all it does is change your shell PATH; you can
explicitly specify the virtualenv's python binary and never use
activation, if you wish.

> http://www.egenix.com/products/python/PyRun/
> It basically takes the "virtual" out of virtualenvs. Instead
> of creating a local symlinked copy of your host Python installation,
> you create a completely separate Python installation (which isn't
> much heavier than a virtualenv due to the way this is done).

Virtualenv doesn't create "a local symlinked copy of your host Python
installation." It copies the binary, symlinks a few key stdlib modules
that are necessary to bootstrap site.py, and then its custom site.py
finds the host Python's stdlib directory and adds it to `sys.path`.

> Once installed, everything works relative to the PyRun binary,
> so you don't need to activate anything when running code inside
> your installation: you just need to run the right PyRun binary
> and this automatically gives you access to everything else
> you installed in your environment.

This is exactly how virtualenv (and pyvenv in Python 3.3+) works.
Everything is relative to the Python binary in the virtualenv (this
behavior is built into the Python executable, actually). You can just
directly run the virtualenv's Python binary (or any script with that
Python binary in its shebang, which includes all pip or easy-installed
scripts in the virtualenv's bin/ dir), without ever activating anything.

It seems the main difference between virtualenv and PyRun is in how much
of the standard library is bundled with each environment, and that I
guess PyRun doesn't come with any convenience activation shell script?
But the method by which "activation" actually occurs is identical (at
least as far as you're described it here.)


> In our latest release, we've added requirements.txt support
> to the installation helper install-pyrun, so that you can
> run
> install-pyrun -r requirements.txt .
> to bootstrap a complete project environment with one command.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150601/32b6d4bf/attachment.sig>

More information about the Python-ideas mailing list