-
Notifications
You must be signed in to change notification settings - Fork 120
SG-40996 prevent config autoupdate #1076
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
base: master
Are you sure you want to change the base?
SG-40996 prevent config autoupdate #1076
Conversation
…et/SG-40996-prevent-config-autoupdate
…m:shotgunsoftware/tk-core into ticket/SG-40996-prevent-config-autoupdate
carlos-villavicencio-adsk
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.
Made some small code style suggestions, but overall looks good. I didn't reviewed the logic because I don't fully understand the goal.
| :returns: True if current Python version is compatible, False otherwise | ||
| """ | ||
| # Get current Python version as string (e.g., "3.9.13") | ||
| current_version_str = ".".join(str(i) for i in sys.version_info[:3]) |
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 think this can be cleaner. Not sure if this is supported by 3.9
| current_version_str = ".".join(str(i) for i in sys.version_info[:3]) | |
| major, minor, micro, *_ = sys.version_info | |
| current_version_str = f"{major}.{minor}.{micro}" |
| log.debug( | ||
| "Local repository at %s is currently at tag %s" | ||
| % (self._path, local_tag) | ||
| ) |
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.
Let's use f-strings.
| return None | ||
| except Exception as e: | ||
| log.debug( | ||
| "Could not determine local repository tag at %s: %s" % (self._path, e) |
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.
Same here f-strings.
| :param latest_tag: Latest tag that was found incompatible | ||
| :param current_py_ver: Current Python version string | ||
| :param min_py_ver: Minimum Python version required by latest_tag | ||
| :returns: local_tag if compatible, None otherwise |
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.
Let's add types on the docstring. Or maybe starts using type annotations in the method signature?
This pull request introduces robust Python version compatibility checks for bundle auto-updates and tag selection in the descriptor system, focusing on git tag descriptors. It ensures that the latest available bundle version is compatible with the running Python interpreter, and gracefully falls back to the highest compatible local or cached version when necessary. The changes also improve error handling and logging for version parsing and compatibility checks.
Python version compatibility enforcement:
_check_minimum_python_versiontobase.pyto verify if the current Python version meets the minimum required version specified in the bundle manifest. This is now used throughout the descriptor logic.git_tag.py, the_get_latest_versionmethod now checks if the latest tag is compatible with the current Python version, and if not, attempts to find the highest compatible version from the local repository or bundle cache, logging warnings when auto-update is blocked.Local and cached version fallback logic:
_get_local_repository_tag,_check_local_tag_compatibility, and_find_compatible_cached_versioningit_tag.pyto support falling back to a compatible local tag or cached version if the latest tag is incompatible.Error handling and logging improvements:
_find_latest_tag_by_patterninbase.pyto skip malformed version tags and log debug messages.General codebase cleanup:
base.pyandgit_tag.py. [1] [2]dict_from_uri.These changes collectively ensure that bundle updates are safe and compatible with the user's Python environment, preventing runtime errors due to version mismatches and providing clear feedback when auto-updates are blocked.