Repository navigation
Install tzdata on windows - #1513
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1513 +/- ##
=======================================
Coverage 94.43% 94.43%
=======================================
Files 27 27
Lines 5051 5051
=======================================
Hits 4770 4770
Misses 281 281
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
akx
left a comment
There was a problem hiding this comment.
I'm not sure we want this extra dependency OOTB, since this hasn't been an issue so far... Chances are user projects needing TZ functionality will have pulled this dependency somehow anyway.
I wonder what happens on Windows in general if tzdata isn't available.
|
I suppose at least partially it's because many frameworks where you're likely to use Babel already depend on As for what happens, this is on Win11: Without >>> from babel.dates import get_timezone
>>> get_timezone()
<babel.localtime._fallback._FallbackLocalTimezone object at 0x000001C69681FCB0>
>>> get_timezone('Europe/Zurich')
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
get_timezone('Europe/Zurich')
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "C:\Users\troun\Desktop\bb\.venv\Lib\site-packages\babel\dates.py", line 258, in get_timezone
raise LookupError(f"Unknown timezone {zone}") from exc
LookupError: Unknown timezone Europe/Zurich^ The local zone gets a fallback and everything else raises a With >>> from babel.dates import get_timezone
>>> get_timezone()
zoneinfo.ZoneInfo(key='Europe/Berlin')
>>> get_timezone('Europe/Zurich')
zoneinfo.ZoneInfo(key='Europe/Zurich')Personally, given the recommendation from the zoneinfo docs and that it's a small 1st-party dependency, I'd include it. Alternatively we can reproduce the warning in our own docs, but honestly I'd prefer to just make it work ™️ |
The zoneinfo docs mention this (on all Python versions we support):
We currently only declare tzdata as a dev dependency, but I believe this should be a regular dependency on Windows (I verified on Win11 that zoneinfo does indeed raise without tzdata installed).
@akx Maybe I'm missing something, but ever since pytz became an optional dependency (which pulled tzdata) we should've included tzdata ourselves?