py_virtualenv attempts to configure a virtual environment by munging PYTHONPATH, but PYTHONPATH is apparently just a way add extra directories to the Python lookup path (not to restrict the list of directories). As such, Python is adding to its search path a bunch of its own "site_packages".
Rather than trying to work around the complicated Python lookup rules, it would probably be better to just use virtualenv directly.
Open Questions
Do we need a target to install virtualenv (can we use python -m venv or something)?
Once we've created the virtualenv, how do we activate it? In bash, it's source ${VENVDIR}/bin/activate, but the concept of "sourcing" is a bashism and doesn't translate directly to subprocesses.
py_virtualenv attempts to configure a virtual environment by munging PYTHONPATH, but PYTHONPATH is apparently just a way add extra directories to the Python lookup path (not to restrict the list of directories). As such, Python is adding to its search path a bunch of its own "site_packages".
Rather than trying to work around the complicated Python lookup rules, it would probably be better to just use virtualenv directly.
Open Questions
python -m venv
or something)?source ${VENVDIR}/bin/activate
, but the concept of "sourcing" is a bashism and doesn't translate directly to subprocesses.