to-mc / checksumdir

Simple package to compute a single deterministic hash of the file contents of a directory.
MIT License
94 stars 28 forks source link

Replaced pkg_resources with importlib.metadata #23

Open idahogray opened 3 years ago

idahogray commented 3 years ago

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.

stefan6419846 commented 1 year ago

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 commented 1 year ago

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.