Closed jaraco closed 5 months ago
How is a project to depend on zoneinfo (or backports.zoneinfo) if the imported package won't be usable?
I ran into this issue on jaraco/tempora#29, where I was asked to port
tempora
frompytz
tozoneinfo
, but I find the Windows tests failing in jaraco/tempora#30.What's the right way to deploy an application that supports Windows and requires zoneinfo and Python 3.8?
zoneinfo
provides a mechanism for working with time zone data, tzdata
provides time zone data, but your system may also provide time zone data, or you may work entirely with your own system that generates TZif files.
Unfortunately, I know of no way to tightly scope your requirements to mean, "My application requires time zone data, and I only want you to depend on tzdata
if the system doesn't provide it." You could simply depend on the tzdata
package unconditionally, or you could declare a conditional dependency that only triggers on windows, or you could add an optional tzdata
dependency and pass the buck to your end users.
In your case, as far as I can tell you don't need pytz
or zoneinfo
(other than in tests, since you will presumably want to test that your users can pass datetimes not in UTC), since the only time zone you seem to use is UTC
, and there's a dedicated UTC
object in the standard library (datetime.timezone.utc
, which in more recent versions of Python has an alias at datetime.UTC
). You are better off using that than zoneinfo.ZoneInfo("UTC")
, though either one is better than pytz
.
After installing
backports.zoneinfo
on Windows, the package fails to construct even a UTC info:It appears it's not possible to construct a UTC instance. It looks like the root issue was reported in #140, that the tzdata is a required dependency but is declared optional.
How is a project to depend on zoneinfo (or backports.zoneinfo) if the imported package won't be usable?
I ran into this issue on https://github.com/jaraco/tempora/issues/29, where I was asked to port
tempora
frompytz
tozoneinfo
, but I find the Windows tests failing in https://github.com/jaraco/tempora/issues/30.What's the right way to deploy an application that supports Windows and requires zoneinfo and Python 3.8?