Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on pytz #1110

Merged
merged 5 commits into from Mar 9, 2023
Merged

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Feb 28, 2023

Since the introduction of PEP 614 PEP 615 (the zoneinfo module in the standard library, available since python 3.9), the future, apparently, is to transition away from pytz to zoneinfo for timezone support.

Babel, since 2.12, will now work with either pytz or zoneinfo, and no longer requires pytz on pythons >= 3.9.

This change also fixes some hokey-ness in the previous implementation of DateTimeType.

Related Issues / Links

See #1109.

Description of Changes

  • Added unit test(s) covering the changes (if testable)

@dairiki dairiki added this to the 3.4 milestone Feb 28, 2023
@dairiki
Copy link
Contributor Author

dairiki commented Mar 1, 2023

Hmmph. Apparently

Some systems, including notably Windows systems, do not have an IANA database available, and so for projects targeting cross-platform compatibility that require time zone data, it is recommended to declare a dependency on tzdata.

I've added pytz back to our dependency list, but only on Windows. Perhaps, for uniformity, we need to keep it for all platforms? OTOH, it's not the end of the world if a user has to manually install pytz if their system doesn't provide a suitable timezone database and they want to use named timezones in their datetime fields.

@CAM-Gerlach
Copy link
Contributor

Hmm; is there a reason to not just add a dependency on tzdata instead, as the message indicates? That just ships the time zone db that zoneinfo needs rather than all of pytz.

@dairiki
Copy link
Contributor Author

dairiki commented Mar 1, 2023

Hmm; is there a reason to not just add a dependency on tzdata instead, as the message indicates?

Because I can't read. Thank you.

Since the introduction of PEP 614 (the `zoneinfo` module in the
standard library, available since python 3.9), the future is to
transition away from `pytz` to `zoneinfo` for timezone support.

Babel, since 2.12, will now work with either `pytz` or `zoneinfo`,
and no longer requires `pytz` on pythons >= 3.9.

This change also fixes some hokey-ness in the previous implementation
of DateTimeType.
@dairiki dairiki merged commit 3ddb731 into lektor:master Mar 9, 2023
@dairiki dairiki deleted the refactor.drop-pytz branch March 9, 2023 01:13
dairiki added a commit to dairiki/lektor that referenced this pull request Sep 11, 2023
* refactor: remove dependency on pytz

Since the introduction of PEP 615 (the `zoneinfo` module in the
standard library, available since python 3.9), the future is to
transition away from `pytz` to `zoneinfo` for timezone support.

Babel, since 2.12, will now work with either `pytz` or `zoneinfo`,
and no longer requires `pytz` on pythons >= 3.9.

This change also fixes some hokey-ness in the previous implementation
of DateTimeType.

* test: test with and without pytz installed

* fix: require tzdata on windows (pytz for python < 3.9)

* docs: fix typos in comment

* test: test with (and without) tzdata installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants