Skip to content

Commit

Permalink
build: use importlib (pkg_resources is deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Dec 10, 2024
1 parent 1cabcc2 commit b4ca7f9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,33 @@ jobs:

- name: Check style
run: python3 -m ruff check . && python3 -m ruff format --check .
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: zsh
version: 1.0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: '**/setup.cfg'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --use-deprecated=legacy-resolver '.[test,postgres,snowflake,queueing]'
- name: Test with pytest
run: pytest tests/storage/test_snowflake.py
9 changes: 3 additions & 6 deletions src/anyvar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
"""Import basic AnyVar objects."""

import logging

import pkg_resources
from importlib.metadata import PackageNotFoundError, version

_logger = logging.getLogger(__name__)

__all__ = ["AnyVar"]


try:
__version__ = pkg_resources.get_distribution(__name__).version
__version__ = version(__name__)
_logger.info("Package %s, version = %s", __name__, __version__)
except pkg_resources.DistributionNotFound:
except PackageNotFoundError:
__version__ = "unknown"
finally:
del pkg_resources


from .anyvar import AnyVar # isort:skip

0 comments on commit b4ca7f9

Please sign in to comment.