Skip to content

Commit 639ffc8

Browse files
DEP: Remove tzdata as a hard dependency outside of Windows (#63335)
Co-authored-by: Joris Van den Bossche <[email protected]>
1 parent 9ee361b commit 639ffc8

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ details, see the commit logs at https://github.com/pandas-dev/pandas.
115115
## Dependencies
116116
- [NumPy - Adds support for large, multi-dimensional arrays, matrices and high-level mathematical functions to operate on these arrays](https://www.numpy.org)
117117
- [python-dateutil - Provides powerful extensions to the standard datetime module](https://dateutil.readthedocs.io/en/stable/index.html)
118-
- [tzdata - Provides an IANA time zone database](https://tzdata.readthedocs.io/en/latest/)
118+
- [tzdata - Provides an IANA time zone database](https://tzdata.readthedocs.io/en/latest/) (Only required on Windows/Emscripten)
119119

120120
See the [full installation instructions](https://pandas.pydata.org/pandas-docs/stable/install.html#dependencies) for minimum supported versions of required, recommended and optional dependencies.
121121

doc/source/getting_started/install.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ Package Minimum support
150150
================================================================ ==========================
151151
`NumPy <https://numpy.org>`__ 1.26.0
152152
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.2
153-
`tzdata <https://pypi.org/project/tzdata/>`__ 2023.3
153+
`tzdata <https://pypi.org/project/tzdata/>`__ \* /
154154
================================================================ ==========================
155155

156+
\* ``tzdata`` is only required on Windows and Pyodide (Emscripten).
157+
156158
Generally, the minimum supported version is ~2 years old from the release date of a major or minor pandas version.
157159

158160
.. _install.optional_dependencies:

doc/source/whatsnew/v3.0.0.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,6 @@ The following required dependencies were updated:
686686
+=================+======================+
687687
| numpy | 1.26.0 |
688688
+-----------------+----------------------+
689-
| tzdata | 2023.3 |
690-
+-----------------+----------------------+
691689

692690
For `optional libraries <https://pandas.pydata.org/docs/getting_started/install.html>`_ the general recommendation is to use the latest version.
693691
The following table lists the lowest version per library that is currently being tested throughout the development of pandas.

pandas/_libs/tslibs/timezones.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ cdef bint is_utc_zoneinfo(tzinfo tz):
5959
utc_zoneinfo = zoneinfo.ZoneInfo("UTC")
6060
except zoneinfo.ZoneInfoNotFoundError:
6161
return False
62-
# Warn if tzdata is too old, even if there is a system tzdata to alert
63-
# users about the mismatch between local/system tzdata
64-
import_optional_dependency("tzdata", errors="warn", min_version="2022.7")
6562

6663
return tz is utc_zoneinfo
6764

pandas/tests/tslibs/test_timezones.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
timedelta,
44
timezone,
55
)
6+
import subprocess
7+
import sys
8+
import textwrap
69

710
import dateutil.tz
811
import pytest
@@ -16,6 +19,25 @@
1619
from pandas import Timestamp
1720

1821

22+
@pytest.mark.single_cpu
23+
def test_no_timezone_data():
24+
# https://github.com/pandas-dev/pandas/pull/63335
25+
# Test error message when timezone data is not available.
26+
msg = "'No time zone found with key Europe/Brussels'"
27+
code = textwrap.dedent(
28+
f"""\
29+
import sys, zoneinfo, pandas as pd
30+
sys.modules['tzdata'] = None
31+
zoneinfo.reset_tzpath(['/path/to/nowhere'])
32+
try:
33+
pd.to_datetime('2012-01-01').tz_localize('Europe/Brussels')
34+
except zoneinfo.ZoneInfoNotFoundError as err:
35+
assert str(err) == "{msg}"
36+
"""
37+
)
38+
subprocess.check_call([sys.executable, "-c", code])
39+
40+
1941
def test_is_utc(utc_fixture):
2042
tz = timezones.maybe_get_tz(utc_fixture)
2143
assert timezones.is_utc(tz)

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ requires-python = '>=3.11'
2929
dependencies = [
3030
"numpy>=1.26.0",
3131
"python-dateutil>=2.8.2",
32-
"tzdata>=2023.3"
32+
"tzdata; sys_platform == 'win32'",
33+
# Emscripten is the platform system for Pyodide.
34+
"tzdata; sys_platform == 'emscripten'",
3335
]
3436
classifiers = [
3537
'Development Status :: 5 - Production/Stable',

0 commit comments

Comments
 (0)