denisenkom / pytds

Python DBAPI driver for MSSQL using pure Python TDS (Tabular Data Stream) protocol implementation
MIT License
190 stars 52 forks source link

chore: remove use of pkg_resources for newer python versions #157

Closed jackwotherspoon closed 7 months ago

jackwotherspoon commented 7 months ago

pkg_resources is vastly seen as deprecated and in the latest Python version it has been removed entirely from being pre-installed as part of Python https://github.com/python/cpython/issues/95299

This results in the following error with Python 3.12 when using pytds:

.nox\system-3-12\Lib\site-packages\pytds\__init__.py:69: in <module>
    import pkg_resources  # type: ignore # fix later
E   ModuleNotFoundError: No module named 'pkg_resources'

To fix this we can leverage importlib.metadata as a replacement for pkg_resources.get_distribution().version

jackwotherspoon commented 7 months ago

@denisenkom let me know if you think this change is acceptable 😄

jackwotherspoon commented 7 months ago

Could also use a version.py instead and read from it as an option

codecov[bot] commented 7 months ago

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (ccd0fca) 89.21% compared to head (d5dbce0) 89.19%.

Files Patch % Lines
src/pytds/utils.py 75.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #157 +/- ## ========================================== - Coverage 89.21% 89.19% -0.02% ========================================== Files 44 44 Lines 8076 8083 +7 ========================================== + Hits 7205 7210 +5 - Misses 871 873 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

denisenkom commented 7 months ago

Yeah, I think this is good. I am thinking in future to simplify it more. The idea is to inject a version as part of a build process, so that during runtime it would be just a constant.

jackwotherspoon commented 7 months ago

Thanks @denisenkom! Just curious when the next release is scheduled be cut so that this change takes effect? 🚀

denisenkom commented 7 months ago

Some time in January 2024