Skip to content

Refactor Pypi fetcher class for re-usability#185

Merged
tdruez merged 1 commit intomasterfrom
pypi-refactored
Nov 28, 2025
Merged

Refactor Pypi fetcher class for re-usability#185
tdruez merged 1 commit intomasterfrom
pypi-refactored

Conversation

@tdruez
Copy link
Contributor

@tdruez tdruez commented Nov 28, 2025

The previous implementation is too restrictive and returns random distribution.

Changes:

  • Add support for no-version PURLs (return latest version)
  • Split the code into several methods for versatility
  • Add the option to provide a preferred_type such as:
>>> from fetchcode.pypi import Pypi

>>> Pypi.get_download_url("pkg:pypi/requests@2.28.0")
'https://files.pythonhosted.org/packages/e9/23/384d9953bb968731212dc37af87cb75a885dc48e0615bd6a303577c4dc4b/requests-2.28.0.tar.gz'

>>> Pypi.get_download_url("pkg:pypi/requests@2.28.0", preferred_type="bdist_wheel")
'https://files.pythonhosted.org/packages/41/5b/2209eba8133fc081d3ffff02e1f6376e3117e52bb16f674721a83e67e68e/requests-2.28.0-py3-none-any.whl'

Signed-off-by: tdruez <tdruez@aboutcode.org>
@tdruez tdruez merged commit b0a6e5a into master Nov 28, 2025
3 checks passed
@tdruez tdruez deleted the pypi-refactored branch November 28, 2025 08:08
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.

1 participant