Skip to content

Conversation

@eduardoChaucaGallegos
Copy link
Contributor

@eduardoChaucaGallegos eduardoChaucaGallegos commented Dec 2, 2025

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:

  • Added _check_minimum_python_version to base.py to verify if the current Python version meets the minimum required version specified in the bundle manifest. This is now used throughout the descriptor logic.
  • In git_tag.py, the _get_latest_version method 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:

  • Implemented _get_local_repository_tag, _check_local_tag_compatibility, and _find_compatible_cached_version in git_tag.py to support falling back to a compatible local tag or cached version if the latest tag is incompatible.

Error handling and logging improvements:

  • Improved error handling in _find_latest_tag_by_pattern in base.py to skip malformed version tags and log debug messages.
  • Enhanced debug and warning logs throughout the new compatibility logic, making it easier to trace fallback decisions and compatibility issues. [1] [2]

General codebase cleanup:

  • Minor import reordering and deduplication for clarity and consistency in both base.py and git_tag.py. [1] [2]
  • Small syntax fixes for consistency, e.g., variable naming in 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.

@eduardoChaucaGallegos eduardoChaucaGallegos marked this pull request as ready for review December 4, 2025 21:01
@eduardoChaucaGallegos eduardoChaucaGallegos requested a review from a team December 4, 2025 21:02
Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk left a 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])
Copy link
Contributor

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

Suggested change
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}"

Comment on lines +262 to +265
log.debug(
"Local repository at %s is currently at tag %s"
% (self._path, local_tag)
)
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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?

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.

3 participants