This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Drop the pyvenv script
Type: behavior Stage: resolved
Components: Installation Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: barry, brett.cannon, doko, eric.smith, ezio.melotti, lac, pitrou, python-dev, rpointel, scoder
Priority: normal Keywords: patch

Created on 2015-09-17 18:35 by brett.cannon, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue25154.diff brett.cannon, 2015-09-25 20:12 review
issue25154-1.diff eric.smith, 2015-10-26 07:49 review
Messages (18)
msg250910 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-09-17 18:35
I propose that the pyvenv script be deprecated in Python 3.5 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, 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 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.
msg250912 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2015-09-17 18:58
I'm sympathetic, given that in Debian/Ubuntu (and maybe other distros) where we have both Python 3.4 and 3.5, we have to install /usr/bin/pyvenv-3.4 and pyvenv-3.5, and then use symlinks to provide the default version.
msg250920 - (view) Author: Laura Creighton (lac) Date: 2015-09-17 21:17
Due to debian policy decision
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732703

neither pyenv nor python -m venv 

may work for you.

While things are getting changed, it would be good if people running into
this problem got a better error message than:

  Error: Command '['<directory>/bin/python3.4', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

such as 'Your python may not be configured with ensure-pip'
msg250923 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-09-17 22:43
the ensurepip case is another issue, so if you want you can file a separate issue for it so it doesn't get lost.
msg251021 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2015-09-18 18:55
I have a patch which will at least improve the error message when `python3 -m venv` fails because python3-venv isn't installed on Debian/Ubuntu.  I will work with Doko on this.
msg251457 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-09-23 21:16
python-dev did not seem to object to the idea.
msg251543 - (view) Author: Remi Pointel (rpointel) * Date: 2015-09-24 19:26
I would prefer to keep this script with the version referring to the version of python used (pyvenv-3.4, pyvenv-3.5, ...).
msg251605 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-09-25 20:12
Here is a patch that adds a message to stderr about the deprecation.
msg253102 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-10-16 22:14
New changeset 6ab285820db2 by Brett Cannon in branch 'default':
Issue #25154: Deprecate the pyvenv script.
https://hg.python.org/cpython/rev/6ab285820db2
msg253185 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-10-19 16:38
I have a typo in my commit where I accidentally placed the file argument in str.format() instead of for print() (pointed out on GitHub).
msg253263 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2015-10-20 22:12
Did you fix the "exeutable" typo?
msg253264 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-10-20 22:14
Not yet. I will get to it no later than Friday (just a matter of either remembering to quickly fix it when I get home from work, bother setting up SSH keys at work, or simply doing it on Friday when I typically do all of my Python work).
msg253385 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2015-10-23 15:56
May I ask how difficult it is for any of the core developers to fix a known typo in a Python source file?
msg253386 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2015-10-23 16:02
Fixing a typo is trivial.  If the typo affects several version the changeset needs to be merged on all the applicable branches before being pushed.
msg253444 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-10-26 00:40
New changeset 7a5f8418b4ab by Brett Cannon in branch 'default':
Issue #25154: Make the file argument apply to the print function and
https://hg.python.org/cpython/rev/7a5f8418b4ab
msg253445 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-10-26 00:41
Sorry for the delay on this; fell ill Friday and then had guests all weekend.
msg253457 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-10-26 07:49
There's a typo here in 'executable':

+          '`{} -m venv`'.format(exeutable), file=sys.stderr)

And this could now be:
    print('WARNING: the pyenv script is deprecated in favour of '
          f'`{executable} -m venv`', file=sys.stderr)

!

And since there is no .format() call, you can't accidentally pass it file=.
msg253508 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-10-27 00:11
Took Eric's advice in 8828d7847e92 as well as actually tested the results this time. :P
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69341
2015-10-27 00:11:39brett.cannonsetstatus: open -> closed

messages: + msg253508
2015-10-26 16:39:44brett.cannonsetstatus: closed -> open
2015-10-26 07:49:03eric.smithsetfiles: + issue25154-1.diff
nosy: + eric.smith
messages: + msg253457

2015-10-26 00:41:13brett.cannonsetstatus: open -> closed

messages: + msg253445
2015-10-26 00:40:40python-devsetmessages: + msg253444
2015-10-23 16:02:27ezio.melottisetnosy: + ezio.melotti
messages: + msg253386
2015-10-23 15:56:13scodersetnosy: + scoder
messages: + msg253385
2015-10-20 22:14:27brett.cannonsetmessages: + msg253264
2015-10-20 22:12:23pitrousetnosy: + pitrou
messages: + msg253263
2015-10-19 16:38:04brett.cannonsetstatus: closed -> open

messages: + msg253185
2015-10-16 22:15:54brett.cannonlinkissue25427 dependencies
2015-10-16 22:15:01brett.cannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-10-16 22:14:34python-devsetnosy: + python-dev
messages: + msg253102
2015-09-25 20:12:34brett.cannonsetfiles: + issue25154.diff
keywords: + patch
messages: + msg251605

stage: needs patch -> patch review
2015-09-24 19:26:19rpointelsetnosy: + rpointel
messages: + msg251543
2015-09-23 21:16:57brett.cannonsetassignee: brett.cannon
messages: + msg251457
2015-09-18 18:55:36barrysetmessages: + msg251021
2015-09-17 22:43:16brett.cannonsetmessages: + msg250923
2015-09-17 21:52:58barrysetnosy: + doko
2015-09-17 21:17:49lacsetnosy: + lac
messages: + msg250920
2015-09-17 18:58:57barrysetmessages: + msg250912
2015-09-17 18:57:36barrysetnosy: + barry
2015-09-17 18:35:21brett.cannoncreate