You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jorisvandenbossche (via GitHub)" <gi...@apache.org> on 2023/12/19 12:57:33 UTC
Re: [PR] GH-37328: [Python] Add a function to download and extract timezone database on Windows [arrow]
jorisvandenbossche commented on code in PR #38179:
URL: https://github.com/apache/arrow/pull/38179#discussion_r1431363822
##########
python/pyarrow/util.py:
##########
@@ -228,3 +228,40 @@ def _break_traceback_cycle_from_frame(frame):
# us visit the outer frame).
refs = gc.get_referrers(frame)
refs = frame = this_frame = None
+
+
+def download_tzdata_on_windows():
+ """
+ Download and extract 2021e IANA timezone database into
+ the expected location in the Downloads directory.
+ """
+ if sys.platform != 'win32':
+ raise TypeError(f"Timezone database is already provided by {sys.platform}")
+
+ import requests
+ import tarfile
+
+ tzdata_path = os.path.expandvars(r"%USERPROFILE%\Downloads\tzdata")
+ tzdata_compressed = os.path.join(tzdata_path, "tzdata.tar.gz")
+ os.makedirs(tzdata_path, exist_ok=True)
+
+ response = requests.get(
+ 'https://data.iana.org/time-zones/releases/tzdata2021e.tar.gz',
Review Comment:
Does that website provide a link that automatically always downloads the latest version?
##########
python/pyarrow/util.py:
##########
@@ -228,3 +228,40 @@ def _break_traceback_cycle_from_frame(frame):
# us visit the outer frame).
refs = gc.get_referrers(frame)
refs = frame = this_frame = None
+
+
+def download_tzdata_on_windows():
+ """
+ Download and extract 2021e IANA timezone database into
+ the expected location in the Downloads directory.
+ """
+ if sys.platform != 'win32':
+ raise TypeError(f"Timezone database is already provided by {sys.platform}")
+
+ import requests
Review Comment:
Given we don't require requests at the moment as a dependency, we could also use the stdlib `urllib.request.urlopen` (it's no problem for a util function like this to have additional dependency requirements, but if there is an easy stdlib alternative, let's just use that to avoid this issue)
##########
python/pyarrow/util.py:
##########
@@ -228,3 +228,40 @@ def _break_traceback_cycle_from_frame(frame):
# us visit the outer frame).
refs = gc.get_referrers(frame)
refs = frame = this_frame = None
+
+
+def download_tzdata_on_windows():
+ """
+ Download and extract 2021e IANA timezone database into
+ the expected location in the Downloads directory.
Review Comment:
Maybe specify what this "expected" location is
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org