What's the problem this feature will solve?
Currently if you're on an older version of pip, you'll get prompted to upgrade your version of pip. This is true even if the newer version of pip does not support the version of Python you are currently operating under.
Describe the solution you'd like
Have the logic that decides whether or not to warn on a new version of pip be smart enough to recognize if there is a newer version of pip, for this version of Python.
This issue is a good 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 and codebase. The relevant file in this case is https://github.com/pypa/pip/blob/master/src/pip/_internal/utils/outdated.py.
Please feel free to mention me (@pradyunsg) if you need some guidance.
Hi. I'm a bit of a newbie to open source, but could I take this issue?
Hi @EternalLearner42! Please feel free to.
Great! I'll take some time to poke around the codebase, and I'll likely pose some concrete questions later, if you don't mind.
No worries. Please feel free to ask questions here.
@pradyunsg Greetings! Sorry for taking so long to reply again, I had a hectic weekend.
After studying the documentation, I have come to the following conclusions:
3.7
The following versions were dropped in the accompanying pip versions:
After analysing the file you submitted, I conclude that it would be better to create another function to check the current version of python and to get the latest version of pip that supports it.
I just have two more questions:
Is there a module already defined throughout the codebase to check the current python version?
How to integrate this new funtion to be created into the codebase?
If I'm overcomplicating this or if you have better ideas on how to address this issue, please let me know!
Sorry for taking so long to reply again, I had a hectic weekend.
Please, don't be.
Your approach sounds good to me. :)
* Is there a module already defined throughout the codebase to check the current python version?
You can use the sys
module: see https://docs.python.org/3/library/sys.html#sys.version_info
* How to integrate this new funtion to be created into the codebase?
Just add it to the file linked earlier, and use it to better filter the list generated around line 135.
to get the latest version of pip that supports it.
Yea, to check the latest version of pip that supports the currently running python, you'll want to get the Python-Requires metadata for the versions of pip available on the package index.
Feel free to ping me again if you want me to elaborate further. :)
Hi @EternalLearner42! Have you been able to find some time to work on this? Is there any blocker for this work that I can help you out with? :)
@EternalLearner42 I have various things in 2.7 which will want to keep using pip in some form or another.
I think having a blessed (and possibly maintained) version or branch to continue with business-as-usual would be much appreciated.
I have various things in 2.7 which will want to keep using pip in some form or another.
I think having a blessed (and possibly maintained) version or branch to continue with business-as-usual would be much appreciated.
What you're asking for is, fairly, unrelated to this issue.
Please see https://discuss.python.org/t/packaging-and-python-2/662. There's been a lot of discussion about Python 2 and Packaging and a separate "fork" is definitely not how we want to go about this.
Greetings! I'm terribly sorry for going dark for all this time.
See, I'm a full time college student, and I started working on this issue in between semesters. As I started the second semester two weeks ago, I sorta let this slip away from me, as I started doing a lot of the course work in advance.
Now however, I am a bit more free, and in fact have already started to write out some code. I expect to submit a PR by the end of the week, though I stress that I am not quite a professional programmer by any means.
If you feel like I am moving to slowly, feel free to give this issue to someone else, though I can assure you that I have not forgotten this, nor will I.
By the way @pradyunsg , what do you mean by "get the Python-Requires metadata for the versions of pip available on the package index"
I find myself a bit confused on this part, where is this package index? Is my former list not accurate?
@EternalLearner42 don't let this undermine your studies. We all have jobs, families, etc to consider when we allocate our time. As I interpret @pradyunsg the various version of pip in the package index are tagged with the version(s) of Python that are supported for that version. I assume this is fetched as needed from pypi.org.
Hey @EternalLearner42!
I'm terribly sorry for going dark for all this time.
It's okay. There's no hurry in doing this. Don't be sorry for your lack of time.
I'm a full time college student
Hey! Me too. 馃憢
don't let this undermine your studies. We all have jobs, families, etc to consider when we allocate our time.
+1
If you feel like I am moving to slowly, feel free to give this issue to someone else, though I can assure you that I have not forgotten this, nor will I.
Don't worry about that. You're progressing just fine. :)
what do you mean by "get the Python-Requires metadata for the versions of pip available on the package index"
Right. I'll elaborate on what I am suggesting, with links to additional material to learn more about the things I am talking about:
You had concluded that:
it would be better to create another function to check the current version of python and to get the latest version of pip that supports it.
This is correct. However, we won't keep an hard-coded list/dictionary of supported versions of pip by Python version. We want this mechanism to also be useful when we drop support for future Python versions in a future pip release.
This is an existing mechanism in Python packaging that allows packages to specify the Python versions that a package is compatible with -- "Requires-Python" metadata (additional information with the package). See https://packaging.python.org/guides/dropping-older-python-versions/.
You can see that this information is available in outdated.py
commenting out lines 114 to line 120 in outdated.py
and adding the following line after all_candidates is assigned:
print(vars(all_candidates[-1]))
print(vars(all_candidates[-1].location))
print(all_candidates[-1].location.requires_python)
Then, running python src/pip install six
(as per https://pip.pypa.io/en/stable/development/getting-started/#running-pip-from-source-tree) will print the relevant details, at the end of the output.
check_requires_python
is a helper defined within pip to see if a given requires_python
string is compatible with the current running interpreter. We want to check if the highest version numbered candidate which also has a compatible requires_python
string, from the all_candidates
list, is what we use for the comparison with pip_version
around line 146.
I suggest you look up the meanings of PyPI and Package Index at https://packaging.python.org/glossary/. :)
I'll leave it as a learning exercise for you to figure out how to bring together all of these parts. Please do feel free to ask any more questions that you feel this isn't enough information, if something in the above is not clear to you or if you have any doubts. :)
Greetings! Due to unforeseen complications during the week, I've only been able to take another look at this now...
I'll try to solve this now during the weekend. Regardless, thanks a lot for being so nice and patient @pradyunsg ! 馃憤
I think this issue can be closed? I came in looking to contribute to a new issue but I am unable to reproduce. Taking a look at the code this doesn't seem to be a problem anymore. The outdated warning now uses the PackageFinder
class here. This class seems to correctly handle using the Python-Requires
metadata (if enabled by selection preferences) here. This preference defaults to False
meaning that this should be properly handled now.
@Raab70 you're right, thanks for pointing it out.
Hopefully you'll find an other issue to contribute to :)
Boy, it feels embarassing to look at this after half a year has passed. Up until last week, I've been swamped with college work, and unable to give this due attention :(
Apologies to all involved, especially @pradyunsg , thank you for all the help and patience, and I hope I can be of actual help in some other issues in the future :)
No need to feel embarrassed @EternalLearner42. :)
Most helpful comment
Hi @EternalLearner42! Have you been able to find some time to work on this? Is there any blocker for this work that I can help you out with? :)