diff --git a/setup.py b/setup.py index cabcc20..ec0b3f4 100644 --- a/setup.py +++ b/setup.py @@ -40,6 +40,6 @@ ] }, url="https://github.com/cs50/style50", - version="2.9.0", + version="2.9.1", include_package_data=True, ) diff --git a/style50/__init__.py b/style50/__init__.py index 1eda055..29839a1 100644 --- a/style50/__init__.py +++ b/style50/__init__.py @@ -1,19 +1,16 @@ -from pkg_resources import get_distribution, DistributionNotFound -import os +import sys +from importlib.metadata import PackageNotFoundError, version -# https://stackoverflow.com/questions/17583443/what-is-the-correct-way-to-share-package-version-with-setup-py-and-the-package +# Require Python 3.8+ +if sys.version_info < (3, 8): + sys.exit("You have an old version of python. Install version 3.8 or higher.") + +# Get version try: - _dist = get_distribution("style50") - # Normalize path for cross-OS compatibility. - _dist_loc = os.path.normcase(_dist.location) - _here = os.path.normcase(__file__) - if not _here.startswith(os.path.join(_dist_loc, "style50")): - # This version is not installed, but another version is. - raise DistributionNotFound -except DistributionNotFound: - __version__ = "locally installed, no version information available" -else: - __version__ = _dist.version + __version__ = version("style50") +except PackageNotFoundError: + __version__ = "UNKNOWN" + __all__ = ["Style50", "languages", "StyleCheck", "Error"] diff --git a/style50/renderer/_renderers.py b/style50/renderer/_renderers.py index 3edf073..dcff78d 100644 --- a/style50/renderer/_renderers.py +++ b/style50/renderer/_renderers.py @@ -2,11 +2,12 @@ import pathlib import jinja2 -import pkg_resources import termcolor +from importlib.resources import files -TEMPLATES = pathlib.Path(pkg_resources.resource_filename("style50.renderer", "templates")) + +TEMPLATES = pathlib.Path(files("style50.renderer").joinpath("templates")) def to_ansi(files, score, version):