Skip to content

Install tzdata on windows - #1513

Merged
akx merged 1 commit into
python-babel:masterfrom
tomasr8:tzdata
Nov 29, 2026
Merged

akx merged 1 commit into
python-babel:masterfrom
tomasr8:tzdata

Conversation

@tomasr8

@tomasr8 tomasr8 commented Nov 28, 2026

Copy link
Copy Markdown
Member

The zoneinfo docs mention this (on all Python versions we support):

Some systems, including notably Windows systems, do not have an IANA database available, and so for projects targeting cross-platform compatibility that require time zone data, it is recommended to declare a dependency on tzdata. If neither system data nor tzdata are available, all calls to ZoneInfo will raise ZoneInfoNotFoundError.

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?

@codecov

codecov Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.43%. Comparing base (394f91a) to head (904c528).

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           
Flag Coverage Δ
macos-26-3.10 93.52% <ø> (ø)
macos-26-3.11 93.46% <ø> (ø)
macos-26-3.12 93.72% <ø> (ø)
macos-26-3.13 93.72% <ø> (ø)
macos-26-3.14 93.70% <ø> (ø)
macos-26-3.15 93.70% <ø> (ø)
macos-26-3.9 93.46% <ø> (ø)
macos-26-pypy3.11 93.42% <ø> (ø)
macos-26-pypy3.12 93.68% <ø> (ø)
ubuntu-24.04-3.10 93.54% <ø> (ø)
ubuntu-24.04-3.11 93.48% <ø> (ø)
ubuntu-24.04-3.12 93.74% <ø> (ø)
ubuntu-24.04-3.13 93.74% <ø> (ø)
ubuntu-24.04-3.14 93.72% <ø> (ø)
ubuntu-24.04-3.15 93.72% <ø> (ø)
ubuntu-24.04-3.9 93.48% <ø> (ø)
ubuntu-24.04-pypy3.11 93.44% <ø> (ø)
ubuntu-24.04-pypy3.12 93.70% <ø> (ø)
windows-2025-3.10 93.61% <ø> (ø)
windows-2025-3.11 93.55% <ø> (ø)
windows-2025-3.12 93.81% <ø> (ø)
windows-2025-3.13 93.81% <ø> (ø)
windows-2025-3.14 93.79% <ø> (ø)
windows-2025-3.15 93.79% <ø> (ø)
windows-2025-3.9 93.55% <ø> (ø)
windows-2025-pypy3.11 93.55% <ø> (ø)
windows-2025-pypy3.12 93.81% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed

codspeed Bot commented Nov 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 88 untouched benchmarks


Comparing tomasr8:tzdata (904c528) with master (394f91a)

Open in CodSpeed

@akx akx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tomasr8

tomasr8 commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

I suppose at least partially it's because many frameworks where you're likely to use Babel already depend on tzdata (like flask-babel, or django) so users might not even notice in the first place..

As for what happens, this is on Win11:

Without tzdata:

>>> 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 LookupError

With tzdata, everything works as expected:

>>> 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 ™️

@akx akx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, fair enough.

@akx
akx merged commit dbba351 into python-babel:master Nov 29, 2026
36 checks passed
@tomasr8
tomasr8 deleted the tzdata branch November 29, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants