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

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

Closed
guw opened this issue Mar 1, 2024 · 3 comments · Fixed by #838
Assignees
Labels
internal cleanup P2 An issue that should be worked on when time is available

Comments

@guw
Copy link
Contributor

guw commented Mar 1, 2024

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 aiuto added P2 An issue that should be worked on when time is available internal cleanup labels Mar 4, 2024
@aiuto
Copy link
Collaborator

aiuto commented Mar 4, 2024

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
Copy link
Contributor

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 aiuto self-assigned this Mar 21, 2024
aiuto added a commit to aiuto/rules_pkg that referenced this issue Mar 21, 2024
@aiuto
Copy link
Collaborator

aiuto commented Mar 21, 2024

SGTM. fix on the way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal cleanup P2 An issue that should be worked on when time is available
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants