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

store all known releases for Python Build Standalone known versions #21776

Merged
merged 6 commits into from
Dec 18, 2024

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Dec 18, 2024

As first mentioned by @huonw in #21710 (review) and more fully discussed in #21748, the addition of filtering PBS releases by the PBS release tag means that users may now see a breaking change if Pants scrapes newer versions of PBS releases, replaces some of the existing "known versions" data with the newly-scraped release metadata, and the user selects an older release via a PBS release constraint.

In that case, the user would see an error because Pants would be unable to select that specific PBS version anymore due to no longer having any metadata regarding that PBS release tag.

The solution is for Pants to store metadata for all PBS release tags. Newer versions will only add to the PBS "known versions" data and not replace nor delete any metadata. With all metadata available, a user who selects a particular PBS release via the release constraints will still continue to see that release be selected. And users who want the latest matching PBS release will continue to get the latest PBS release (known to Pants).

Closes #21748.

import json
import re
import sys

with open(sys.argv[1]) as f:
  data = json.load(f)

DIGITS_RE = re.compile("^\d+")

python_versions_to_delete = []

for python_version, releases_for_python in data["pythons"].items():
  releases_to_delete = []
  for release_name, platforms_for_release in releases_for_python.items():
     if not DIGITS_RE.match(release_name):
       releases_to_delete.append(release_name)

  for release_name in releases_to_delete:
    del releases_for_python[release_name]

  if not releases_for_python:
    python_versions_to_delete.append(python_version)

for python_version in python_versions_to_delete:
  del data["pythons"][python_version]

with open(sys.argv[1], 'w') as f:
  f.write(json.dumps(data, sort_keys=True, indent=2))
@tdyas
Copy link
Contributor Author

tdyas commented Dec 18, 2024

It is helpful to review the commits individually.

@tdyas tdyas requested a review from benjyw December 18, 2024 02:18
Copy link
Contributor

@huonw huonw left a comment

Choose a reason for hiding this comment

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

Nice fix, thank you!

@tdyas tdyas merged commit 627d533 into pantsbuild:main Dec 18, 2024
24 checks passed
@tdyas tdyas deleted the pbs/store-all-releases-data branch December 18, 2024 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:bugfix Bug fixes for released features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PBS python provider release_constraints needs fine-tuning to avoid back-compat risk
2 participants