sdispater / pendulum

Python datetimes made easy
https://pendulum.eustace.io
MIT License
6.27k stars 385 forks source link

Use system provided tzdata as a priority #769

Open tuukkamustonen opened 1 year ago

tuukkamustonen commented 1 year ago

Issue

Pendulum uses tzdata package and imports the tzdata in https://github.com/sdispater/pendulum/blob/75a87a4e3cab45c5f9c38ca6060a54337dcadd09/src/pendulum/tz/__init__.py#L28

However, tzdata package's docs state:

It is generally recommended that any time zone libraries should attempt to use the system data before using the tzdata package

Should Pendulum rather look into system provided files first, and only resort to tzdata if the data is not found?

It's of course easier to just import from Python's tzdata package. Simiarly, if system provided data was used as a priority, then there would be need for a mechanism to override the system-provided data with Python's tzdata package (if OS provided tzdata is too old / incomplete).

So, might not be actionable.

mgorny commented 11 months ago

In fact, it's a violation of PEP 615 and as such, the package can't work on PEP 615-conformant Linux distributions that do not provide vendored tzdata, such as Gentoo.

mgorny commented 11 months ago

Also, I think the bug report is about 3.0.0.

mgorny commented 11 months ago

To be honest, I can't figure out what this is supposed to do. It seems to grab the list of timezones from tzdata, except that tzdata is not used anywhere else and system zoneinfo package is used instead which is going to prefer using system tzdata, so the list is effectively meaningless (in the best case it will match zoneinfo.available_timezones(), in the worst it will be mismatched to timezones actually supported). What's even more confusing is that pendulum.utils._zoneinfo seems to wrap available_timezones but it isn't used anywhere else.