Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 801280 - dev-python/pytzdata: doesn't install zoneinfo files
Summary: dev-python/pytzdata: doesn't install zoneinfo files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jakov Smolić
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-09 07:17 UTC by Sam Jorna (wraeth)
Modified: 2021-07-09 14:44 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Jorna (wraeth) gentoo-dev 2021-07-09 07:17:17 UTC
zoneinfo files provided with the pytzdata package are not installed:

> ❯ ebuild $(ew dev-python/pytzdata) clean unpack
>  * pytzdata-2020.1.tar.gz BLAKE2B SHA512 size ;-) ...  [ ok ]
>  * checking ebuild checksums ;-) ...                   [ ok ]
>  * checking miscfile checksums ;-) ...                 [ ok ]
> >>> Unpacking source...
> >>> Unpacking pytzdata-2020.1.tar.gz to /var/tmp/portage/dev-python/pytzdata-2020.1/work
> >>> Source unpacked in /var/tmp/portage/dev-python/pytzdata-2020.1/work
> 
> ❯ ls /var/tmp/portage/dev-python/pytzdata-2020.1/work/pytzdata-2020.1/pytzdata/zoneinfo 
> Africa      Arctic    Australia  Chile   Indian   US       Cuba   Eire     Factory  GMT    GMT0       HST      iso3166.tab  Japan        Libya  MST7MDT  NZ-CHAT   posixrules  ROC        Turkey     Universal  W-SU          Zulu
> America     Asia      Brazil     Etc     Mexico   CET      EET    EST      GB       GMT+0  Greenwich  Iceland  Israel       Kwajalein    MET    Navajo   Poland    PRC         ROK        tzdata.zi  UTC        zone1970.tab
> Antarctica  Atlantic  Canada     Europe  Pacific  CST6CDT  Egypt  EST5EDT  GB-Eire  GMT-0  Hongkong   Iran     Jamaica      leapseconds  MST    NZ       Portugal  PST8PDT     Singapore  UCT        WET        zone.tab
> 
> ❯ =emerge -pvqO dev-python/pytzdata
> [ebuild   R   ] dev-python/pytzdata-2020.1  USE="-test" PYTHON_TARGETS="python3_9 -python3_10 -python3_8"
> 
> ❯ qlist dev-python/pytzdata | grep zoneinfo
> (no output)

Because of this, attempting to use the package as-is causes failure as it defaults to using its self-provided zoneinfo:

> python3
> Python 3.9.6 (default, Jun 30 2021, 10:20:12) 
> [GCC 11.1.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pytzdata
> >>> pytzdata.tz_file('Australia/Sydney')
> Traceback (most recent call last):
>   File "/usr/lib/python3.9/site-packages/pytzdata/__init__.py", line 32, in tz_file
>     filepath = tz_path(name)
>   File "/usr/lib/python3.9/site-packages/pytzdata/__init__.py", line 74, in tz_path
>     raise TimezoneNotFound('Timezone {} not found at {}'.format(name, filepath))
> pytzdata.exceptions.TimezoneNotFound: Timezone Australia/Sydney not found at /usr/lib/python3.9/site-packages/pytzdata/zoneinfo/Australia/Sydney
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "/usr/lib/python3.9/site-packages/pytzdata/__init__.py", line 46, in tz_file
>     return resource_stream(__name__, 'zoneinfo/' + name)
>   File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1136, in resource_stream
>     return get_provider(package_or_requirement).get_resource_stream(
>   File "/usr/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1608, in get_resource_stream
>     return open(self._fn(self.module_path, resource_name), 'rb')
> FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.9/site-packages/pytzdata/zoneinfo/Australia/Sydney'
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/lib/python3.9/site-packages/pytzdata/__init__.py", line 48, in tz_file
>     return tz_path(name)
>   File "/usr/lib/python3.9/site-packages/pytzdata/__init__.py", line 74, in tz_path
>     raise TimezoneNotFound('Timezone {} not found at {}'.format(name, filepath))
> pytzdata.exceptions.TimezoneNotFound: Timezone Australia/Sydney not found at /usr/lib/python3.9/site-packages/pytzdata/zoneinfo/Australia/Sydney

This can be worked around by instructing the package to use the system zoneinfo files:

> PYTZDATA_TZDATADIR=/usr/share/zoneinfo python3
> Python 3.9.6 (default, Jun 30 2021, 10:20:12) 
> [GCC 11.1.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import pytzdata
> >>> pytzdata.tz_file('Australia/Sydney')
> <_io.BufferedReader name='/usr/share/zoneinfo/Australia/Sydney'>

Are the zoneinfo data files intentionally not being installed?

If so, then ideally either the default data path should be updated to use the system zoneinfo files so the module functions correctly by default, or at least a postinst message should be shown noting that the PYTZDATA_TZDATADIR environment variable must be set for the module to be used.

If not, then an extra step may be required in the ebuild to install the data files to the appropriate location for each python implementation being built for.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-07-09 07:58:02 UTC
Eh, another half-broken NIH package suite...
Comment 2 Larry the Git Cow gentoo-dev 2021-07-09 14:44:43 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=03b481085bc20e6c9ea57a15335054256eb33cb4

commit 03b481085bc20e6c9ea57a15335054256eb33cb4
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2021-07-09 08:19:33 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2021-07-09 14:44:15 +0000

    dev-python/pytzdata: Use system zoneinfo by default
    
    Closes: https://bugs.gentoo.org/801280
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 .../files/pytzdata-2020.1-system-zoneinfo.patch    | 115 +++++++++++++++++++++
 ...ata-2020.1.ebuild => pytzdata-2020.1-r1.ebuild} |   9 +-
 2 files changed, 121 insertions(+), 3 deletions(-)