Skip to content
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

utils/pypi: default to formula version when using package_name #16771

Merged
merged 1 commit into from Mar 6, 2024

Conversation

cho-m
Copy link
Member

@cho-m cho-m commented Feb 29, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

When using package_name, we currently end up dropping the version information. For example,

brew update-python-resources black
==> Retrieving PyPI dependencies for "black[d]"...
==> Retrieving PyPI dependencies for excluded ""...
...

vs. removing package_name:

brew update-python-resources black
==> Retrieving PyPI dependencies for "black==24.2.0"...
==> Retrieving PyPI dependencies for excluded ""...

This can potentially lead to incorrect resolution if the formula version is not the latest version.


With change, the default version is obtained from the formula:

brew update-python-resources black
==> Retrieving PyPI dependencies for "black[d]==24.2.0"...
==> Retrieving PyPI dependencies for excluded ""...

One potential issue is if the formula version scheme is different from PyPI formula scheme.

If we hit this and there is no other solution, then I think we could add a way of bypassing this inside pypi_formula_mappings.json (e.g. an extra field like unversioned: true or without_version: true or some other name)

Signed-off-by: Michael Cho <michael@michaelcho.dev>
@cho-m
Copy link
Member Author

cho-m commented Feb 29, 2024

I tested out all formulae in homebrew-core's pypi_formula_mappings.json that use package_name feature and only one that doesn't work is buku.

However, buku is broken because upstream did not upload PyPI package and trying to get dependency tree from buku[server] fails due to bad dependency, e.g.

pipgrip 'buku[server]'
ERROR: Getting report for flask-reverse-proxy-fix@ https://github.com/rachmadaniHaryono/flask-reverse-proxy-fix/archive/refs/tags/v0.2.2rc1.zip failed with output:
error: subprocess-exited-with-error

There is a workaround possible by using our formula source url instead, e.g.

pipgrip 'buku[server] @ https://github.com/jarun/buku/archive/refs/tags/v4.8.tar.gz'
buku @ https://github.com/jarun/buku/archive/refs/tags/v4.8.tar.gz
arrow==1.3.0
...

Can look into this later on (e.g. maybe try PyPI first and then fall back to URL).

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @cho-m!

@cho-m
Copy link
Member Author

cho-m commented Mar 6, 2024

I think this is ready. Need a final review.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @cho-m!

@MikeMcQuaid MikeMcQuaid merged commit 5a68dea into Homebrew:master Mar 6, 2024
26 checks passed
@cho-m cho-m deleted the pypi-package_name-version branch March 6, 2024 16:35
@github-actions github-actions bot added the outdated PR was locked due to age label Apr 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants