Enhance Compatibility for Python Versions Below 3.8 #1135
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.
Hi,
I've popped in a pull request to propose a small yet significant enhancement to the [umap package/project]. This enhancement aims to improve the package's compatibility with Python versions below 3.8, ensuring a broader user base can benefit from its powerful features without facing import errors.
Currently, the package utilizes
importlib.metadatafor importingversionandPackageNotFoundError, which is available in Python 3.8 and newer versions. However, this leads to compatibility issues with older Python versions, as they lack this module, potentially alienating a segment of the user base still on these versions.To address this issue, I have implemented a conditional import strategy in the
__init__.pyfile. The code attempts to importversionandPackageNotFoundErrorfromimportlib.metadata(available in Python 3.8+). If this import fails (indicating the user is on an older Python version), it falls back to importing the same modules from theimportlib_metadatapackage, which is a backport ofimportlib.metadatafor older Python versions.