I'm inclined to add an option and suggest in the message how to suppress the message itself, using pip config.
@pradyunsg Is it okay to discuss this in a separate issue / PR so this can be merged?
_Originally posted by @cjerdonek in https://github.com/pypa/pip/pull/6208#issuecomment-459924175_
So, how do we suppress the 2.7 deprecation message with pip config
?
@pradyunsg I think this should go in the next release in some form — unless you’re planning another patch release not long after. My concern is that if the message is too annoying without an easy way to suppress, it could dissuade people from using this version of pip. I admit though I haven’t checked to see in what circumstances (e.g. which commands) the message currently displays.
@defjaf I’m pretty sure there’s not currently a way to do it with pip config, which is why he said “add an option” in the original comment above.
I admit though I haven’t checked to see in what circumstances (e.g. which commands) the message currently displays.
All invocations on Python 2.7.
I think this should go in the next release in some form — unless you’re planning another patch release not long after.
I am not warm to the idea of making a 19.0 series release, post 19.0.2.
If someone is willing to write a PR to suppress python-version related deprecation warnings in pip, I'm OK to get them in the next release but I won't block 19.0.2 on it. If it misses that window, this would have to wait till 19.1, which will be in April.
Some context from the coal face:
I have some C/C++ code using Conan to build with dependencies on various libraries.
I had a hard time making Conan happy on Raspberry Pi due to ARM and limited memory.
Having _pip_ warn me about "end of days" and giving me no practical reason to wrangle Python 3 onto the device is not useful or valuable in this context.
Especially the 27th time than Conan failed to build something.
Overall the experience decreased my confidence in both Conan and Python/Pip suitability for the task.
It works on Linux. It works on Mac. But will it work in 2020? Maybe the font will be red and language will be scarier sounding? What is the point of that?
In other words: I suggest to simply remove the message. It's simply not actionable from my point of view, Python 2.7 will continue to need pip, regardless of 2020.
Additional discussion on this issue occurred here: https://discuss.python.org/t/pip-19-0-is-now-available/757
@nigels-com I've modified your message to have a slightly milder tone, to avoid it contributing to potentially burning out contributors and other maintainers of pip.
If you don't find that edit appropriate, please free free to ping me anywhere _other than on this issue_ (like my username @gmail.com or on twitter by the same username or in a new issue on this repo).
@pradyunsg I'm supportive of your effort to keep things mild. We in 2.7 land just want to get on with things without undue or unintended friction.
Personally, I think anyone who wants to help "get this fixed" is welcome to help us take #6126 forward, which is a long term fix for this issue and related issues.
That would provide a mechanism to users who don't care about certain kinds of messages to silence them while allowing the maintainers to provide useful hints to users who might not know as much.
If you care about silencing the Python 2.7 depreciation message, you should also be willing to set certain configuration options to disable such messages. #6126 is the mechanism to suppress such messages.
So, no, I'm personally not amicable to removing this message. I am amicable to providing a decent mechanism to hide this error message and genuinely prefer a general mechanism for filtering messages from within pip.
Thanks!
We in 2.7 land just want to get on with things without undue or unintended friction.
I understand and empathize. I don't disagree with your requirement -- we should provide you a mechanism to silence that message. I don't think removing it for everyone is the right way to do it. :)
FWIW, you can suppress that message today with an environment variable:
~PYTHONWARNINGS=ignore:Please.upgrade::pip._internal.cli.base_command
~
~(From #6147)~
PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command
An _opt-out_ policy is a step in the right direction. Appreciated.
@pradyunsg Note that my suggested filter was actually broken, and @kylegibson posted a corrected one at https://github.com/pypa/pip/pull/6147#issuecomment-466790523:
PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command
Edited my comment -- thanks!
I think we can break this issue into 2 smaller issues, each of which can be worked on independently:
--no-warn-python-version
, like #4553 added --no-warn-script-location
I don't want to block this on #6126.These would both be good first issues for first time contributors. If no one voices any concerns, I'm going to do this and close this issue sometime in the next 24 hours.
hello there, if you're reading this, please let me know if there are any improvements I can make to the issue descriptions below.
There is a feature request to be able to silence Python version related warnings that pip emits (try running pip 19 on Python 2.7 to see what that means).
The way we want to handle this request is to add a new flag/command line option, similar to --no-warn-script-location
to pip, in pip._internal.cli.cmdoptions.general_group
(as named in code) and using that within pip's BaseCommand
class for putting the version-based checking under a conditional.
Additional references:
See #4553 for how --no-warn-script-locations
is implemented.
where general options are defined
where general options get added
where to add conditional
This is a moderately complex issue that can serve as starting point for anyone who wants to help out with pip's development -- the process of fixing this should be a good introduction to pip's development workflow.
The error message that pip prints when run on Python 2.7 is not very informative about what timeline pip would use before dropping support or how it might approach it.
I can't wait to still be dealing with The Python Every Non-Trivial Software System Having Made The Mistake Uses vs. The Python They Want You To Use in 2030 (as if ANSI-decorated messages will have had any effect to the contrary).
Anyway, there is a cleaner alternative to setting the PYTHONWARNINGS
environment variable in order to silence this, as long as user site customization has not been disabled:
import os, site
if site.ENABLE_USER_SITE: os.path.join(site.getusersitepackages(), 'usercustomize.py')
# -> '/home/mdl/.local/lib/python2.7/site-packages/usercustomize.py'
Hooray. Now squirt this into that file:
try:
import warnings
warnings.filterwarnings('ignore', 'DEPRECATION',
module='pip._internal.cli.base_command')
except ImportError: pass
Ride the snake.
references: #6147, #6207, #6208, #6231
next 24 hours.
lol me.
Closing this in favor of #6673 and #6674.