[Python-Dev] Proposing the deprecation of the pyvenv script

Brett Cannon bcannon at gmail.com
Thu Sep 17 20:40:25 CEST 2015


I opened http://bugs.python.org/issue25154 for this idea and below is
what I put in the issue as to why I think we should deprecate the
pyvenv script in favour of `python3 -m venv`.


I propose that the pyvenv script be deprecated in Python 3.5.1 and
removed in Python 3.8. The reason for this proposal is because it is
non-obvious what version of Python a pyvenv command is tied to (heck,
it isn't necessarily obvious that it's Python 3). There would be no
loss in functionality since the exact same functionality is available
through `python3 -m venv`. This is a backwards-compatibility change,
hence the deprecation, but changing various shell scripts and such
should be trivial thanks to the -m flag. This would also help promote
the use of -m, especially for any projects that rely on being tied to
a specific installed interpreter.

As pointed out in issue #25152 <http://bugs.python.org/issue25152>,
virtualenv provides a -p flag to specify what version of Python should
be used to create a virtual environment:
https://virtualenv.pypa.io/en/latest/reference.html#virtualenv-command.
The pyvenv script and venv package provide no such mechanism since it
is included in the stdlib, which makes sense since improvements will
be tied to the stdlib of the Python interpreter being used while
virtualenv is a standalone project/app.

Some may argue that worrying about this is unnecessary, but we are
already ending up with OSs that come with multiple versions of Python
pre-installed, let alone when people install their own versions of
Python on top of the system installation. For instance, OS X Yosemite
comes with Python 2.6 and 2.7, and then if you install the latest
version of Python independently you end up with 3 installations. If
they all happened to have a pyvenv script you wouldn't easily know
which Python interpreter the pyvenv command was going to use for the
virtual environment.

Since the pyvenv script is just a script, the deprecation will be in
the form of a message printed to sys.stderr in the
Tools/scripts/pyvenv
<http://hg.python.org/cpython/file/default/Tools/scripts/pyvenv> file
mentioning that the deprecation and that people should switch to
`python3 -m venv` instead. The long deprecation cycle is for those who
have pyvenv provided by their OS and only upgrade Python every few
years, and thus run the risk of missing the deprecation warning. As
for the deprecation in Python 3.5.1, that's to get the warning out
immediately and to minimize people missing the deprecation prior to
the removal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150917/dfe38f61/attachment.html>


More information about the Python-Dev mailing list