trinodb / trino-python-client

Python client for Trino
Apache License 2.0
327 stars 163 forks source link

API incompatibility with tzlocal #436

Closed nikmartin closed 8 months ago

nikmartin commented 8 months ago

Expected behavior

Using trino works

Actual behavior

Traceback (most recent call last):
  File "D:\GISApps\ETL\NationalNetworkTransform\python_source\ImportBuildings.py", line 25, in <module>
    from trino.dbapi import connect
  File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\SpectrumETL\lib\site-packages\trino\__init__.py", line 13, in <module>
    from . import auth, client, constants, dbapi, exceptions, logging
  File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\SpectrumETL\lib\site-packages\trino\auth.py", line 28, in <module>
    from trino.client import exceptions
  File "C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\SpectrumETL\lib\site-packages\trino\client.py", line 61, in <module>
    from tzlocal import get_localzone_name  # type: ignore
ImportError: cannot import name 'get_localzone_name' from 'tzlocal' (C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\SpectrumETL\lib\site-packages\tzlocal\__init__.py)

Steps To Reproduce

My Python environment is 3.7.9. I installed trino, and am not sure if it installed tzlocal, or it was already in the environment, but the version of tzlocal is 5.1. 5.1 has several API changes over previous versions, one of which is get_localzone_name is no longer an import, you call it as a funtion

Log output

No response

Operating System

Windows Server 2019

Trino Python client version

0.327

Trino Server version

N/A

Python version

3.7.9

Are you willing to submit PR?

nikmartin commented 8 months ago

According to https://github.com/regebro/tzlocal/blob/52e53725f86fd74e551965de4e3a9f3aee826c8d/README.rst#L125, the object get_localzone_name no longer exists in tzlocal 4.0 and >

nikmartin commented 8 months ago

I may be mis-reading the tzlocal docs, the function IS an import and should exist in 4.01b and >

nikmartin commented 8 months ago

I misread the version of tzlocal, it was 2.x