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

FIX: Update version checking to importlib to remove pkg_resources. #48

Merged
merged 3 commits into from
Mar 11, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
create-args: >-
python=${{matrix.python-version}}
conda
- name: Fetch all history for all tags and branches
run: |
git fetch --prune --unshallow
- name: Set up conda environment
run: |
python -m pip install -e .
Expand Down
2 changes: 2 additions & 0 deletions ci/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ dependencies:
- pooch
- pre-commit
- pytest-cov
- setuptools
- setuptools-scm
6 changes: 3 additions & 3 deletions open_radar_data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3
# flake8: noqa
"""Top-level module for pythia-datasets ."""
from pkg_resources import DistributionNotFound, get_distribution
import importlib.metadata as _importlib_metadata

from .dataset import DATASETS, locate

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound: # pragma: no cover
__version__ = _importlib_metadata.version("open-radar-data")
except _importlib_metadata.PackageNotFoundError: # pragma: no cover
# package is not installed
__version__ = 'unknown' # pragma: no cover
4 changes: 2 additions & 2 deletions open_radar_data/dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pkg_resources
import importlib.resources
import pooch

DATASETS = pooch.create(
Expand All @@ -7,7 +7,7 @@
env='OPEN_RADAR_DATA_DIR',
)

with pkg_resources.resource_stream('open_radar_data', 'registry.txt') as registry_file:
with open(importlib.resources.files('open_radar_data') / 'registry.txt') as registry_file:
DATASETS.load_registry(registry_file)


Expand Down