Skip to content

Commit

Permalink
Merge pull request #1443 from phargogh/bugfix/1442-pkg_resources-depr…
Browse files Browse the repository at this point in the history
…ecated-as-an-api

Updating how we get version information from package metadata
  • Loading branch information
davemfish authored Nov 6, 2023
2 parents 03d3c45 + 957596d commit 2cafe8b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ Unreleased Changes
* Removed the ``utils`` functions ``array_equals_nodata``,
``exponential_decay_kernel_raster``, and ``gaussian_decay_kernel_raster``,
which were obsoleted by new ``pygeoprocessing`` features.
* Version metadata at import time is now fetched with
``importlib.metadata`` instead of ``pkg_resources``.
(`#1442 <https://github.com/natcap/invest/issues/1442>`_)
* Pollination
* Replaced custom kernel implementation with ``pygeoprocessing.kernels``.
Convolution results may be slightly different (more accurate).
Expand Down
6 changes: 3 additions & 3 deletions src/natcap/invest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
"""init module for natcap.invest."""
import importlib.metadata
import logging
import os
import sys
from gettext import translation

import babel
import pkg_resources

LOGGER = logging.getLogger('natcap.invest')
LOGGER.addHandler(logging.NullHandler())
__all__ = ['local_dir', ]

try:
__version__ = pkg_resources.get_distribution(__name__).version
except pkg_resources.DistributionNotFound:
__version__ = importlib.metadata.version('natcap.invest')
except importlib.metadata.PackageNotFoundError:
# package is not installed. Log the exception for debugging.
LOGGER.exception('Could not load natcap.invest version information')

Expand Down

0 comments on commit 2cafe8b

Please sign in to comment.