Skip to content

Commit

Permalink
Remove __version__ as it is not useful
Browse files Browse the repository at this point in the history
It causes problem when pkg_resources or metadata package is not present.
Example issue: #160
If somebody needs version they can use metadata or pkg_resources packages directly.
  • Loading branch information
denisenkom committed Sep 1, 2024
1 parent 585547b commit 70a83a1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ docs/_build
/.cache/
/.pytest_cache/
/tests/.connection.json
/venv
/venv311
7 changes: 1 addition & 6 deletions src/pytds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,8 @@
from .tds_base import logger

__author__ = "Mikhail Denisenko <[email protected]>"
try:
__version__ = utils.package_version("python-tds")
except Exception:
__version__ = "DEV"


intversion = utils.ver_to_int(__version__)
intversion = utils.ver_to_int("1.0.0")

#: Compliant with DB SIG 2.0
apilevel = "2.0"
Expand Down
11 changes: 0 additions & 11 deletions src/pytds/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
import typing
from collections.abc import Callable

if sys.version_info < (3, 8):
import pkg_resources
else:
from importlib import metadata

logger = logging.getLogger("pytds")
T = typing.TypeVar("T")

Expand Down Expand Up @@ -88,9 +83,3 @@ def ver_to_int(ver: str) -> int:
return 0
maj, minor, _ = ver.split(".")
return (int(maj) << 24) + (int(minor) << 16)


def package_version(name: str) -> str:
if sys.version_info < (3, 8):
return pkg_resources.get_distribution(name).version
return metadata.version(name)

0 comments on commit 70a83a1

Please sign in to comment.