Skip to content

Commit

Permalink
Remove the use of pkg_resources (spacetelescope#8095)
Browse files Browse the repository at this point in the history
Co-authored-by: Howard Bushouse <[email protected]>
  • Loading branch information
WilliamJamieson and hbushouse authored Nov 30, 2023
1 parent 0f6a93b commit 2a70810
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ htmlcov
requirements-min.txt
.tox/
.tmp/
jwst/_version.py
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ general

- Remove upper version limit for scipy. [#8033]

- Remove the use of ``pkg_resources`` by ``jwst``. [#8095]

outlier_detection
-----------------

Expand Down
17 changes: 5 additions & 12 deletions jwst/__init__.py
Original file line number Diff line number Diff line change
@@ -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.")
16 changes: 1 addition & 15 deletions jwst/associations/pool.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ requires = [
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "jwst/_version.py"

[tool.ruff]
line-length = 130
Expand Down

0 comments on commit 2a70810

Please sign in to comment.