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

Add Python 3.13 support and loosen protobuf version constraint #2075

Open
bkeryan opened this issue Jan 28, 2025 · 2 comments · May be fixed by #2080
Open

Add Python 3.13 support and loosen protobuf version constraint #2075

bkeryan opened this issue Jan 28, 2025 · 2 comments · May be fixed by #2080
Labels

Comments

@bkeryan
Copy link
Contributor

bkeryan commented Jan 28, 2025

Description of issue

The current stable release of Python is version 3.13, which was released on 10-7-2024.

There are versioning conflicts between nimi-python's grpc extra and Python 3.13:

  • nimi-python's grpc extra requires protobuf>=4.21.6,<5.0.
  • The first version of grpcio and grpcio-tools with binary wheels for Python 3.13 is version 1.67.0
  • grpcio-tools version 1.67.0 requires protobuf version <6.0dev,>=5.26.1.

This causes issues when upgrading ni-measurement-plugin-sdk-service's dev/test dependencies, since it depends on grpcio-tools for gRPC codegen and several nimi-python packages for testing.

PS C:\dev\measurement-plugin-python\packages\service> poetry lock --no-update
Resolving dependencies... (4.9s)

Because no versions of niswitch match >1.4.4,<1.4.5 || >1.4.5,<1.4.6 || >1.4.6,<1.4.7 || >1.4.7,<1.4.8 || >1.4.8
 and niswitch[grpc] (1.4.4) depends on protobuf (>=4.21,<5.0), niswitch[grpc] (>=1.4.4,<1.4.5 || >1.4.5,<1.4.6 || >1.4.6,<1.4.7 || >1.4.7,<1.4.8 || >1.4.8) requires protobuf (>=4.21,<5.0).
And because niswitch[grpc] (1.4.5) depends on protobuf (>=4.21,<5.0), niswitch[grpc] (>=1.4.4,<1.4.6 || >1.4.6,<1.4.7 || >1.4.7,<1.4.8 || >1.4.8) requires protobuf (>=4.21,<5.0).
And because niswitch[grpc] (1.4.6) depends on protobuf (>=4.21,<5.0)
 and niswitch[grpc] (1.4.7) depends on protobuf (>=4.21,<5.0), niswitch[grpc] (>=1.4.4,<1.4.8 || >1.4.8) requires protobuf (>=4.21,<5.0).
And because niswitch[grpc] (1.4.8) depends on protobuf (>=4.21.6,<5.0)
 and grpcio-tools (1.67.0) depends on protobuf (>=5.26.1,<6.0dev), niswitch[grpc] (>=1.4.4) is incompatible with grpcio-tools (1.67.0).
So, because ni-measurement-plugin-sdk-service depends on both niswitch[grpc] (>=1.4.4) and grpcio-tools (1.67.0), version solving failed.

The protobuf package follows semantic versioning, so I think it was reasonable to use >=4.21,<5.0 based on what we knew about it, but based on what I've seen with nidaqmx-python, it appears that output from grpcio-tools 1.49.1 works with both protobuf v4 and v5. I was able to change nidaqmx-python's protobuf version constraint from ^4.21 (aka >=4.21,<5.0) to >=4.21: ni/nidaqmx-python#645

System report

python -c "import niscope; niscope.print_diagnostic_information()" output (replace niscope with appropriate package name)

N/A, can't install

Steps to reproduce issue

  1. Download https://github.com/ni/measurement-plugin-python/tree/users/bkeryan/python-3.13
  2. cd to packages/service
  3. poetry lock --no-update
@ni-jfitzger
Copy link
Collaborator

@bkeryan For some reason, the pb2 files generated with grpcio-tools 1.67.0 resulted in a protobuf dependency of 5.27.2, despite the clear declaration of compatibility with 5.26.1.

from google.protobuf.internal import builder as _builder
_runtime_version.ValidateProtobufRuntimeVersion(
    _runtime_version.Domain.PUBLIC,
    5,
    27,
    2,
    '',
    'nidcpower.proto'
)

I had to set my tests env protobuf dependency to 5.27.2 to get the unit tests to pass. With 5.26.1, I ran into import errors.

This was referenced Feb 5, 2025
@bkeryan
Copy link
Contributor Author

bkeryan commented Feb 5, 2025

I think you should generate code with the oldest supported Python and grpcio-tools version, check the generated code into version control, and then test against newer versions.

#2080 (comment)

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

Successfully merging a pull request may close this issue.

2 participants