-
Notifications
You must be signed in to change notification settings - Fork 38
feat: add pypi-info command to retrieve package information from PyPI #829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add a new command 'pypi-info' that queries the PyPI JSON API to retrieve comprehensive package information including: - Package name, version, and availability status - License information - Homepage and repository URLs - Distribution type availability (sdist/wheel) The command supports both latest version queries and specific version lookups with proper error handling for missing packages/versions. Example usage: fromager pypi-info requests fromager pypi-info "requests==2.32.0" fromager pypi-info --pypi-base-url https://custom.pypi.org/pypi requests Example of output: ``` $ fromager pypi-info requests 23:04:52 INFO Fetching information for requests Package: requests Version: 2.32.5 Found on PyPI: Yes License: Apache-2.0 Homepage: https://requests.readthedocs.io Repository: https://github.com/psf/requests Has source distribution (sdist): Yes Has wheel: Yes 23:04:52 INFO Package information retrieved successfully for requests 2.32.5 ``` Includes comprehensive unit tests (13 test cases) and e2e integration tests covering all functionality including error conditions and edge cases. Co-Authored-By: Claude <noreply@anthropic.com> claude-sonnet-4@20250514 Signed-off-by: Emilien Macchi <emacchi@redhat.com>
tiran
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a similar idea. Let's get together on Monday.
| default="https://pypi.org/pypi", | ||
| help="Base URL for PyPI JSON API", | ||
| ) | ||
| @click.argument("package_spec", required=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about you make this two arguments: fromager pypi-info torch 2.7.1 with version as an optional argument?
| # License information | ||
| license_info = info.get("license") or "Not specified" | ||
| # Handle cases where license is empty string or None | ||
| if not license_info or license_info.strip() == "": | ||
| license_info = "Not specified" | ||
| print(f"License: {license_info}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to handle several additional special cases. License information can be in three fields. Try fromager pypi-info fromager and fromager pypi-info cryptography to see two special cases.
| print("Homepage: Not specified") | ||
|
|
||
| # Check for other relevant URLs | ||
| project_urls = info.get("project_urls") or {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| project_urls = info.get("project_urls") or {} | |
| project_urls = info.get("project_urls", {}) |
| has_sdist = False | ||
| has_wheel = False | ||
|
|
||
| for url_info in urls: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On recurring problem we have is packages with only prerelease versions, which are not resolved by default. It would be useful to show that sort of detail here when no version is specified.
|
I'm closing the PR, this was experimental. This work can be restored later. |
Add a new command 'pypi-info' that queries the PyPI JSON API to retrieve
comprehensive package information including:
The command supports both latest version queries and specific version
lookups with proper error handling for missing packages/versions.
Example usage:
fromager pypi-info requests
fromager pypi-info "requests==2.32.0"
fromager pypi-info --pypi-base-url https://custom.pypi.org/pypi requests
Example of output:
Includes comprehensive unit tests (13 test cases) and e2e integration tests
covering all functionality including error conditions and edge cases.
Co-Authored-By: Claude noreply@anthropic.com claude-sonnet-4@20250514
Signed-off-by: Emilien Macchi emacchi@redhat.com