-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sbachmei/mic 5755/improve supported py version handling #136
Merged
stevebachmeier
merged 5 commits into
main
from
sbachmei/mic-5755/improve-supported-py-version-handling
Jan 7, 2025
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1f39084
validate python version during setup
stevebachmeier 782c2e9
automatically update README with supported py versions
stevebachmeier e88d6c3
auto-generate github action build matrix
stevebachmeier f9ca85a
update README with supported Python versions
actions-user 1cc10bf
changelog
stevebachmeier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# ----------------------------------------------------------------------------- | ||
# - invoked on push to any branch | ||
# ----------------------------------------------------------------------------- | ||
name: update README | ||
|
||
on: push | ||
|
||
jobs: | ||
update-readme: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
- name: Update README | ||
run: | | ||
pip install packaging | ||
python update_readme.py | ||
- name: Commit and push changes | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "github-actions" | ||
git diff --quiet && git diff --staged --quiet || ( | ||
git add README.rst | ||
git commit -am "update README with supported Python versions" | ||
git pull --rebase origin ${{ github.ref_name }} | ||
git push origin ${{ github.ref_name }} | ||
) | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[build-system] | ||
requires = ["packaging", "setuptools"] | ||
|
||
[tool.black] | ||
line_length = 94 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["3.11", "3.12"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" This script updates the README.rst file with the latest information about | ||
the project. It is intended to be run from the github "update README" workflow. | ||
""" | ||
|
||
import json | ||
import re | ||
|
||
from packaging.version import parse | ||
|
||
# Load supported python versions | ||
with open("python_versions.json", "r") as f: | ||
versions = json.load(f) | ||
versions_str = ", ".join(versions) | ||
versions = [parse(v) for v in versions] | ||
max_version = max(versions).base_version | ||
|
||
# Open README and replace python versions | ||
with open("README.rst", "r") as file: | ||
readme = file.read() | ||
# Update the list of supported python versions | ||
# NOTE: this regex assumes the version format is always major.minor | ||
readme = re.sub( | ||
r"Supported Python versions:\s*(?:\d+\.\d+\s*,\s*)+\d+\.\d+", | ||
r"Supported Python versions: " + versions_str, | ||
readme, | ||
) | ||
# Update the python version used in the installation code snipped example | ||
readme = re.sub(r"python=\d+\.\d+", "python=" + max_version, readme) | ||
|
||
# Write the updated README back to file | ||
with open("README.rst", "w") as file: | ||
file.write(readme) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Did this to test that the
update-readme
action kicks off and changes these back automatically