Skip to content

Honor non-exact version specifiers in the PyPI availability pre-check (fixes #461) - #466

Open
federicocabrera1978-svg wants to merge 1 commit into
PyAr:masterfrom
federicocabrera1978-svg:issue_461_pypi_precheck_specifiers
Open

federicocabrera1978-svg wants to merge 1 commit into
PyAr:masterfrom
federicocabrera1978-svg:issue_461_pypi_precheck_specifiers

Conversation

@federicocabrera1978-svg

Copy link
Copy Markdown

Fixes #461.

_pypi_head_package used the version of the first specifier to build a version-specific URL, even for non-exact specifiers. So requests<3 was checked as requests==3 and reported as non-existent, and ranges could also give false positives.

Now:

  • Exact pins (==X without wildcards, or ===X) keep using /pypi/<name>/<version>/json.
  • Any other specifier (ranges, ~=, !=, ==X.*, combinations) fetches /pypi/<name>/json and passes only if at least one release with files satisfies the specifier (using SpecifierSet.filter, so pre-releases are considered only when no final release matches, like pip).
  • Dependencies without a specifier are checked by name as before.

Added the parametrized test proposed in the issue, plus wildcard and != cases. It fails on master (foo<3, foo>=2.1, foo>=1,<2, foo==2.*) and passes with this change. Full suite: 377 passed.

Note: unrelated to this PR, 12 existing tests fail with logassert 8.7 (latest) and pass with 8.6; happy to open a separate issue.

The PyPI availability pre-check took the version of the first specifier
and asked PyPI for that exact version, even for ranges like 'foo<3' or
'foo>=2.1', giving false negatives (and false positives).

Now the version specific URL is only used for exact pins ('==' without
wildcards, or '==='); for any other specifier the project's releases are
fetched and the check passes only if at least one release (with files)
satisfies the specifier.
@facundobatista

Copy link
Copy Markdown
Member

Hello Federico! We'll take a look at this, thanks!

Regarding logassert: it was fixed, there was a small regression, be sure to update it to 8.8.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PyPI availability pre-check uses the first specifier's version even for non-exact specifiers

2 participants