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

Use importlib metadata version since setuptools pkg_resources is deprecated #1183

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
13 changes: 5 additions & 8 deletions openhtf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
"""The main OpenHTF entry point."""

import importlib.metadata
import signal
import typing

Expand All @@ -36,7 +37,6 @@
from openhtf.util import functions
from openhtf.util import logs
from openhtf.util import units
import pkg_resources

__all__ = ( # Expliclty export certain API components.
# Modules.
Expand Down Expand Up @@ -133,14 +133,11 @@


def get_version():
"""Returns the version string of the 'openhtf' package.

Note: the version number doesn't seem to get properly set when using ipython.
"""
"""Returns the version string of the 'openhtf' package."""
try:
return pkg_resources.get_distribution('openhtf')
except pkg_resources.DistributionNotFound:
return 'Unknown - Perhaps openhtf was not installed via setup.py or pip.'
return importlib.metadata.version('openhtf')
except importlib.metadata.PackageNotFoundError:
return 'Unknown - openhtf not installed via pip.'


__version__ = get_version()
Expand Down