MCPcopy Create free account
hub / github.com/apache/arrow / download_tzdata_on_windows

Function download_tzdata_on_windows

python/pyarrow/util.py:250–293  ·  view source on GitHub ↗

r""" Download and extract latest IANA timezone database into the location expected by Arrow which is %USERPROFILE%\Downloads\tzdata. .. deprecated:: 24.0.0 This function is deprecated and will be removed in a future version. PyArrow now uses the operating system's timezone

()

Source from the content-addressed store, hash-verified

248# TODO(GH-48593): Remove when libc++ supports std::chrono timezone
249# https://github.com/apache/arrow/issues/48593
250def download_tzdata_on_windows():
251 r"""
252 Download and extract latest IANA timezone database into the
253 location expected by Arrow which is %USERPROFILE%\Downloads\tzdata.
254
255 .. deprecated:: 24.0.0
256 This function is deprecated and will be removed in a future version.
257 PyArrow now uses the operating system's timezone database on Windows.
258 """
259
260 warnings.warn(
261 "pyarrow.util.download_tzdata_on_windows is deprecated as of 24.0.0 "
262 "and will be removed in a future version. PyArrow now uses the "
263 "operating system's timezone database on most Windows builds.",
264 FutureWarning,
265 stacklevel=2
266 )
267 if sys.platform != 'win32':
268 raise TypeError(f"Timezone database is already provided by {sys.platform}")
269
270 import tarfile
271
272 tzdata_url = "https://data.iana.org/time-zones/tzdata-latest.tar.gz"
273 tzdata_path = os.path.expandvars(r"%USERPROFILE%\Downloads\tzdata")
274 tzdata_compressed_path = os.path.join(tzdata_path, "tzdata.tar.gz")
275 windows_zones_url = "https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml" # noqa
276 windows_zones_path = os.path.join(tzdata_path, "windowsZones.xml")
277 os.makedirs(tzdata_path, exist_ok=True)
278
279 # Try to download the files with requests and then fall back to urllib. This
280 # works around possible issues in certain older environment (GH-45295)
281 try:
282 import requests # noqa: F401
283 download_fn = _download_requests
284 except ImportError:
285 download_fn = _download_urllib
286
287 download_fn(tzdata_url, tzdata_compressed_path)
288 download_fn(windows_zones_url, windows_zones_path)
289
290 assert os.path.exists(tzdata_compressed_path)
291 assert os.path.exists(windows_zones_path)
292
293 tarfile.open(tzdata_compressed_path).extractall(tzdata_path)

Callers 1

Calls 3

TypeErrorFunction · 0.50
joinMethod · 0.45
openMethod · 0.45

Tested by 1