Skip to content

[RFC] The next generation of virtualenv #1366

Closed
@gaborbernat

Description

@gaborbernat

Following the discussion in 1362 it became apparent that for virtualenv to be able to support the new world (Windows Store installs, venv interpreters) we need some major change of direction.

Here's my proposal for going ahead with this project. This will be a major refactor for the project, that plans to keep existing interface compatibility though.

Project goal

  • create a fresh copy of the system (invoker) python that has its own custom, separately controllable package list,
  • an interface and behaviour that's as much as possible consistent across all supported Python environments (e.g. backport new venv features to older interpreters),
  • extensible (both creation and shell activation script support wise),
  • PyPi package (ability to upgrade out of band with interpreter).

Planned features

  • universal pypi wheel,

  • cross-platform - Windows, all UNIX flavours, MacOS.

  • support for most supported pythons, the initial pool of supported Python version: python2.7, python3.4, python3.5, python3.5, pypy3, pypy2 (hoping for IronPython and Jython at some point - any other ones we should support?)

  • A two year grace period of support: our interface will keep the interpreter support for two more years past its EOL: creating virtual environments is so basic that this package is the last one that should drop compatibility. During this transitional two years period, we guarantee bug fixes and compatibility. New feature support is a best effort though.

  • ability to specify the target python (we'll use PEP-514/PEP-394/explicit link to discover these versions) and create virtual environments even if that target does not have this package installed

  • prefer built-in venv: if the target python has venv we'll create the environment using that (and then perform subsequent operations on that to facilitate other guarantees we offer)

  • ability to provision seed packages (after the creation of the virtual environments this packages will be already installed):

    • we accept PEP-508 format,
    • ability to reach out to PyPi to get latest matching the spec, or offline only (such install packages must be offline)
    • by default pip, setuptools and wheel are the seed packages (these packages are also automatically injected as offline wheel packages)
  • interfaces:

    • CLI interface (python -m virtualenv, virtualenv)
    • wheel interface (env PYTHONPATH=/t/path/to/virtualenv.whl python -m virtualenv) - universal wheel,
    • zipapp interface,
    • API interface: import virtualenv; virtualenv.create("target")
  • shell support - activation/deactivation scripts and prompt environment variables - by default we generate:

    • bash / zsh,
    • csh,
    • fish,
    • powershell,
    • xonsh,
    • cmd,
    • python,
    • a well-defined API to install custom shell scripts (maybe as part of the plugin system).
  • three-layered configuration system, each option is determined as follows:

    • first, ini configuration support (a global ini config present in the users home),
    • second, environment variables having the VIRTUALENV_ prefix,
    • finally, command line options (argparse powered)
  • plugin system these are extension points the user can inject their own custom logic, and generate an extended version of virtualenv (current bootstrapping logic):

    • extend parser (add your own custom CLI flags),
    • adjust options (change options after CLI parse),
    • after install (perform some operation once the virtual environment creation is done)
  • virtualenv support - the operation should work even if the invoking python is a virtualenv created python,

  • venv support - the operation should work even if the invoking python is a virtualenv created python,

  • relocatable environments: an environment should keep working as long as the root python is not removed from the OS (e.g. renaming the root environment folder should not break things).

Difference from stdlib venv

How we differ from the standard library venv? The virtualenv package plans to be:

  • a PyPi package, as such will be more often upgraded, easier to keep up to date and offer feature parity across pythons,
  • built-in interpreter discovery and cross interpreter support,
  • more interfaces (zippapp, wheel, installed package),
  • easier customization - plugin system,
  • be the testing ground for new features (which down the line may make it into venv),
  • longer EOL.

In general, offer features that other downstream tools (for example tox, pre-commit, pipenv, pipsi, pipx) who need virtual environments as an API would want.

PyPy members (and the public please too) share your thoughts or plus one if you agree. @pfmoore @dstufft @di @pradyunsg @cjerdonek @ncoghlan @jaraco @techalchemy @uranusjr @pganssle @benoit-pierre @dholth @lkollar @takluyver @zooba

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions