I'd like to submit a patch for this but I have a few questions :)
First I'll describe what I'd like to do...
See https://pypi.org/simple/pre-commit/
You'll notice that 0.10.0 erroneously sorts before 0.2.0 (I'd like to fix this)
I've found the code which does this sorting here
This seems to just sort by filename, but by inspecting and viewing this page I notice it seems to ignore _ vs. - (which is good, that's what I want to continue to happen but I'm just not seeing it from the code!)
The File objects which come back from the database contain a .version attribute that I'd like to use to participate in sorting, my main question is: Can I depend on this version to be a valid PEP440 version and use something like pkg_resources.parse_version?
I'd basically like to replicate something close to the sorting which @chriskuehl's dumb-pypi does here.
Thanks in advance :)
Good First Issue: This issue is good for first time contributors. If there is not a corresponding pull request for this issue, it is up for grabs. For directions for getting set up, see our Getting Started Guide. If you are working on this issue and have questions, please feel free to ask them here, #pypa-dev on Freenode, or the pypa-dev mailing list.
It does just sort by filename, largely because the order doesn't really matter, as long as it's stable between page loads. That being said, I wouldn't turn down a PR that does this. The version attributes are not guaranteed to be PEP 440 compatible (some of them are old enough that they predate PEP 440). Ideally you're use packaging.version.parse_version which will handle that case fine.
@dstufft if it sorts by filename, I would expect the following sorting on this page: https://pypi.org/simple/pre-commit-mirror-maker/
[
'pre-commit-mirror-maker-0.1.0.tar.gz',
'pre-commit-mirror-maker-0.1.1.tar.gz',
'pre-commit-mirror-maker-0.1.2.tar.gz',
'pre-commit-mirror-maker-0.2.0.tar.gz',
'pre-commit-mirror-maker-0.3.0.tar.gz',
'pre-commit-mirror-maker-0.3.1.tar.gz',
'pre-commit-mirror-maker-0.3.2.tar.gz',
'pre-commit-mirror-maker-0.4.0.tar.gz',
'pre_commit_mirror_maker-0.3.2-py2-none-any.whl',
'pre_commit_mirror_maker-0.4.0-py2-none-any.whl',
'pre_commit_mirror_maker-0.4.0-py3-none-any.whl',
]
but the wheel files are properly sorted alongside their source distributions -- does postgres normalize this?
I don't honestly recall the specifics of how it sorts other than it was by filename.
Awesome, thanks for the prompt replies :) I'll do some more digging!
Hey @cryvate - thanks for your PR. Let us know how it's going?
/cc @di
@yeraydiazdiaz @alanbato @HndrkMkt @waseem18 @mariatta @Volcyy @jw @aalmazan @asottile if one of you would like to take this issue, please speak up here. Feel free to build on @cryvate's work in #2574, and if you're directly reusing it, you can use the --author flag to indicate that someone else authored a commit you're making.
@cryvate, if I'm misunderstanding and you intend on coming back to finish that PR in the next couple weeks, please speak up and let me know. Thanks.
@brainwane Sure thing. Will take a look at it later tonight.
Apologies. I have finally made/found an environment that allows me to run the tests locally, so I am on this (again). @brainwane @aalmazan @di
Most helpful comment
Apologies. I have finally made/found an environment that allows me to run the tests locally, so I am on this (again). @brainwane @aalmazan @di