Skip to content

Add PEP 440 version_specifier filter to ContentPackagesApi.list() #1277

Description

@smoparth

Is your feature request related to a problem? Please describe.
The version filter on GET /content/python/packages/ does string comparison, not PEP 440 semantic comparison. This causes incorrect results for:

Epochs: 1!2.0.0 breaks string comparison entirely
Compound specifiers (>=2.4,<3.0), compatible release (~=2.4), and not-equal (!=2.4.0) have no filter equivalent
We work around this by querying by name (indexed) and filtering client-side with packaging.specifiers.SpecifierSet, which works but pushes PEP 440 logic to every consumer.
Pre-releases: version__gt=2.0 returns 2.0.0rc1 (lexicographically "2.0.0rc1" > "2.0") but PEP 440 says 2.0.0rc1 < 2.0.0
Post-releases: version__gt=2.0.0 excludes 2.0.0.post1 (lexicographically "2.0.0.post1" < "2.0.0") but PEP 440 says 2.0.0.post1 > 2.0.0

Describe the solution you'd like
A version_specifier query parameter on ContentPackagesApi.list() that accepts PEP 440 specifier strings:

GET /content/python/packages/?name=torch&version_specifier=>=2.4,<3.0
GET /content/python/packages/?name=numpy&version_specifier=~=1.26
GET /content/python/packages/?name=scipy&version_specifier=!=1.11.0
Server-side filtering using packaging.specifiers.SpecifierSet to handles PEP 440 specifiers.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
packaging is already a dependency of pulp_python. The PythonRemote sync filtering already does PEP 440 matching server-side. It would be great to have this along with available scope filter like repository and others.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions