diff --git a/.gitignore b/.gitignore index 696ea51037..40f61eced5 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ htmlcov requirements-min.txt .tox/ .tmp/ +jwst/_version.py diff --git a/CHANGES.rst b/CHANGES.rst index e6effad2dc..9e4e60bc84 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -43,6 +43,8 @@ general - Remove upper version limit for scipy. [#8033] +- Remove the use of ``pkg_resources`` by ``jwst``. [#8095] + outlier_detection ----------------- diff --git a/jwst/__init__.py b/jwst/__init__.py index 2387336de2..4320a4c8eb 100644 --- a/jwst/__init__.py +++ b/jwst/__init__.py @@ -1,19 +1,12 @@ import re -import sys -from pkg_resources import get_distribution, DistributionNotFound -__version_commit__ = '' -_regex_git_hash = re.compile(r'.*\+g(\w+)') +from importlib.metadata import version -try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: - __version__ = 'dev' +__version__ = version(__name__) -if '+' in __version__: +_regex_git_hash = re.compile(r".*\+g(\w+)") +__version__commit__ = "" +if "+" in __version__: commit = _regex_git_hash.match(__version__).groups() if commit: __version_commit__ = commit[0] - -if sys.version_info < (3, 9): - raise ImportError("JWST requires Python 3.9 and above.") diff --git a/jwst/associations/pool.py b/jwst/associations/pool.py index 458880df75..3d625f57fb 100644 --- a/jwst/associations/pool.py +++ b/jwst/associations/pool.py @@ -1,9 +1,6 @@ """ Association Pools """ - -from pkg_resources import parse_version, get_distribution - from collections import UserDict from astropy.io.ascii import convert_numpy @@ -134,15 +131,4 @@ def convert_func(vals): return [(convert_func, type_)] -class _ConvertToStr(dict): - def __getitem__(self, k): - return _convert_to_str() - - def get(self, k, default=None): - return self.__getitem__(k) - - -if parse_version(get_distribution('astropy').version) >= parse_version('5.0.dev'): - convert_to_str = {'*': _convert_to_str()} -else: - convert_to_str = _ConvertToStr() +convert_to_str = {'*': _convert_to_str()} diff --git a/pyproject.toml b/pyproject.toml index 9e3c242f60..dc6f0ca81d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,7 @@ requires = [ build-backend = "setuptools.build_meta" [tool.setuptools_scm] +write_to = "jwst/_version.py" [tool.ruff] line-length = 130