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

Include version and checksum validation when updating packages #27

Merged
merged 6 commits into from
Sep 17, 2024

Conversation

agriyakhetarpal
Copy link
Member

@agriyakhetarpal agriyakhetarpal commented Sep 11, 2024

This PR closes #24. Here, we now check against two conditions when updating the package

  • whether the version is up to date plus valid, and
  • whether the SHA-256 checksum matches the one present in the recipe file.

Therefore, updating the package has three scenarios, and here is a summary of what happens:

  • local version updated manually to the newest available PyPI version ➡️ checksums will be updated, too
  • both version and checksum are out of date ➡️ both of them will be updated (as it was before these changes)
  • the checksum is correct and the version is out of date ➡️ this is enough information for us to proceed with updating the version

Additionally, there's now a case where one manually updates the version (in error, for example), to a version that is not released or available on PyPI (yet), which means that the metadata for the version won't exist either. We raise an exception early here, asking the user so that they can check the version while updating. This is a rare situation, so it's more about raising a helpful error that aids the user in debugging the problem. I have skipped adding a test for such a case, but I can add one if needed. Please let me know your thoughts!

@agriyakhetarpal
Copy link
Member Author

Some tests always fail for me locally due to differences in errors from assert statements, but this is probably because my default shell is not bash. I think these changes should be fine here, but I'll trigger the integration tests so that we are sure.

@agriyakhetarpal
Copy link
Member Author

I guess coverage isn't configured yet, it's the same for other PRs, too.

Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

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

Thanks @agriyakhetarpal! We haven't been maintaining skeleton command that much, so it is nice you are working on it.

Comment on lines 261 to 270
if pypi_ver <= local_ver:
raise MkpkgFailedException(
f"Local version {local_ver} is newer than PyPI version {pypi_ver}, "
f"cannot update {package}. Please verify in case the version was "
"updated manually and is correct."
)

# conditions to check if the package is up to date
is_sha256_up_to_date = sha256 == sha256_local
is_version_up_to_date = pypi_ver <= local_ver
Copy link
Member

Choose a reason for hiding this comment

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

When pypi_ver <= local_ver is true, it fails with exception, but is_version_up_to_date checks the same condition after the exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops! Thanks for noticing. 143b729 fixes this – the version comparison should be made in equality (pypi_ver == local_ver), and the impossible update scenario should have a strict greater-than (pypi_ver < local_ver).

Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

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

@agriyakhetarpal
Copy link
Member Author

Thanks for the review!

@agriyakhetarpal agriyakhetarpal merged commit ca7c0e2 into pyodide:main Sep 17, 2024
6 checks passed
@agriyakhetarpal agriyakhetarpal deleted the fix/checksum-validation branch September 17, 2024 01:37
@agriyakhetarpal agriyakhetarpal mentioned this pull request Sep 17, 2024
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.

pyodide skeleton pypi --update does not completely validate checksums when updating
2 participants