checksumdir icon indicating copy to clipboard operation
checksumdir copied to clipboard

Replaced pkg_resources with importlib.metadata

Open idahogray opened this issue 3 years ago • 2 comments

Use of pkg_resources is discouraged in favor of importlib.resources and importlib.metadata. importlib.metadata is used in this commit to get the version string from the pyproject.toml package configuration.

This PR closes #22 in order to hopefully allow PyOxidizer to package the library.

idahogray avatar Apr 18 '21 16:04 idahogray

This will break compatibility in https://github.com/to-mc/checksumdir/blob/5c7a70327cbd8c767b72faa1e2ace2335c3feea5/pyproject.toml#L14

as importlib.metadata is only available since Python 3.8. Older Python versions (like supported by this project) require using the backport in importlib-metadata.

stefan6419846 avatar Jun 06 '23 13:06 stefan6419846

As already mentioned, just requiring importlib_metadata; python_version < "3.8" (or dropping Python < 3.8 completely) and writing

try:
    from importlib.metadata import version
except ImportError:
    # Python < 3.8
    from importlib_metadata import version

would fix this for every supported version since Python 3.6.

stefan6419846 avatar Sep 14 '23 09:09 stefan6419846