Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the use of pkg_resources #8095

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -43,6 +43,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
Loading