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

Python: Deprecation warnings for _descriptor #71

Open
jsa34ito opened this issue Nov 11, 2020 · 4 comments
Open

Python: Deprecation warnings for _descriptor #71

jsa34ito opened this issue Nov 11, 2020 · 4 comments

Comments

@jsa34ito
Copy link

jsa34ito commented Nov 11, 2020

Version: 0.0.6
Python version: 3.9
OS: Fedora 33

Issue:
GTFS realtime bindings for Python are reporting a deprecation warning for EnumDescriptor(), EnumValueDescriptor(), FileDescriptor(), FieldDescriptor(), Descriptor()

Example:

WARNING - .../local/lib/python3.9/site-packages/google/transit/gtfs_realtime_pb2.py:381: DeprecationWarning: Call to deprecated create function FieldDescriptor(). Note: Create unlinked descriptors is going to go away. Please use get/find descriptors from generated code or query the descriptor_pool.
  _descriptor.FieldDescriptor(

@jsa34ito jsa34ito changed the title Python: Deprecation warning for FieldDescriptor() Python: Deprecation warnings for _descriptor Nov 11, 2020
@jsa34ito jsa34ito reopened this Nov 11, 2020
@barbeau
Copy link
Member

barbeau commented Nov 12, 2020

Thanks @jsa34ito. I hope to update the Python bindings soon and hopefully this will fix this issue. I'll leave it open so you can provide feedback on the next release.

@jamespfennell
Copy link

It looks like this deprecation warning was just upgraded to a hard error, and the Python bindings here don't work anymore on fresh builds. The protobuf PyPI package was updated a few hours ago. The build error I get is:

 gtfsrealtimegenerator.py:1: in <module>
     from google.transit import gtfs_realtime_pb2
 /usr/local/lib/python3.9/site-packages/google/transit/gtfs_realtime_pb2.py:50: in <module>
     _descriptor.EnumValueDescriptor(
 /usr/local/lib/python3.9/site-packages/google/protobuf/descriptor.py:755: in __new__
     _message.Message._CheckCalledFromGeneratedFile()
 E   TypeError: Descriptors cannot not be created directly.
 E   If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
 E   If you cannot immediately regenerate your protos, some other possible workarounds are:
 E    1. Downgrade the protobuf package to 3.20.x or lower.
 E    2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
 E   
 E   More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

The version of the Python proto library in setup.py is not pinned, so fresh builds are picking up this new release.

@jamespfennell
Copy link

I tried to upgrade the bindings using the most recent version of the proto compiler and the Python library, but was unable to get the tests to pass due to this error:

ModuleNotFoundError: No module named 'google.protobuf'

I'm very confused because I just ran pip install protobuf...

As a quick alternative, I created a PR that just pins the Python protobuf library at a 3.X.X version.

@jamespfennell
Copy link

Update: the 4.21.0 protobuf was yanked from PyPI because many projects has similar issues to the one here. This is the protobuf GitHub issue. One of the last comments say there will be a roll forward, so the issue here will return soon.

I think the safest option would be to:

  1. Merge in the PR I sent last night and create a new release. This would mean that when the update to the protobuf library happens, gtfs-realtime-bindings will not be affected (as long as consumers upgrate their gtfs-realtime-bindings version).

  2. When the protobuf update happens, create a new PR to actually update the bindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants