bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
214 stars 167 forks source link

Deprecation Warning in `build_zip.py` `datetime.datetime.utcfromtimestamp()` is deprecated and scheduled for removal in a future version #826

Closed guw closed 3 months ago

guw commented 4 months ago

I started to see this on MacOS Sonoma 14.3.1:

INFO: From PackageZip ...:
.../external/rules_pkg/pkg/private/zip/build_zip.runfiles/core/../rules_pkg/pkg/private/zip/build_zip.py:77: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
  ts = datetime.datetime.utcfromtimestamp(ts)

Might be related to a recent brew upgrade?

aiuto commented 4 months ago

A newer Python must have deprecated it. This should be easy to fix. The only constraint is that we don't pick an API which is only in the most recent Pythons.

pauldraper commented 3 months ago

Yes, this is deprecated in Python 3.12.

datetime: datetime.datetime’s utcnow() and utcfromtimestamp() are deprecated and will be removed in a future version. Instead, use timezone-aware objects to represent datetimes in UTC: respectively, call now() and fromtimestamp() with the tz parameter set to datetime.UTC.

Fortunately, datetime.fromtimestamp has been available ~forever.

aiuto commented 3 months ago

SGTM. fix on the way