grpcio-tools

Protobuf code generator for gRPC

258 个版本 Python >=3.10
安装
pip install grpcio-tools
poetry add grpcio-tools
pipenv install grpcio-tools
conda install grpcio-tools
描述

gRPC Python Tools

Package for gRPC Python tools.

Supported Python Versions

Python >= 3.6

Installation

The gRPC Python tools package is available for Linux, macOS, and Windows.

Installing From PyPI


If you are installing locally...

::

  $ pip install grpcio-tools

Else system wide (on Ubuntu)...

::

  $ sudo pip install grpcio-tools

If you're on Windows make sure that you installed the :code:`pip.exe` component
when you installed Python (if not go back and install it!) then invoke:

::

  $ pip.exe install grpcio-tools

Windows users may need to invoke :code:`pip.exe` from a command line ran as
administrator.

n.b. On Windows and on macOS one *must* have a recent release of :code:`pip`
to retrieve the proper wheel from PyPI. Be sure to upgrade to the latest
version!

You might also need to install Cython to handle installation via the source
distribution if gRPC Python's system coverage with wheels does not happen to
include your system.

Installing From Source

Building from source requires that you have the Python headers (usually a package named :code:python-dev) and Cython installed. It further requires a GCC-like compiler to go smoothly; you can probably get it to work without GCC-like stuff, but you may end up having a bad time.

::

$ export REPO_ROOT=grpc # REPO_ROOT can be any directory of your choice $ git clone -b RELEASE_TAG_HERE https://github.com/grpc/grpc $REPO_ROOT $ cd $REPO_ROOT $ git submodule update --init

$ cd tools/distrib/python/grpcio_tools $ python ../make_grpcio_tools.py

For the next command do sudo pip install if you get permission-denied errors

$ GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .

You cannot currently install Python from source on Windows. Things might work out for you in MSYS2 (follow the Linux instructions), but it isn't officially supported at the moment.

Troubleshooting


Help, I ...

* **... see compiler errors on some platforms when either installing from source or from the source distribution**

  If you see

  ::

    /tmp/pip-build-U8pSsr/cython/Cython/Plex/Scanners.c:4:20: fatal error: Python.h: No such file or directory
    #include "Python.h"
                    ^
    compilation terminated.

  You can fix it by installing `python-dev` package. i.e

  ::

    sudo apt-get install python-dev

  If you see something similar to:

  ::

    third_party/protobuf/src/google/protobuf/stubs/mathlimits.h:173:31: note: in expansion of macro 'SIGNED_INT_MAX'
    static const Type kPosMax = SIGNED_INT_MAX(Type); \\
                               ^

  And your toolchain is GCC (at the time of this writing, up through at least
  GCC 6.0), this is probably a bug where GCC chokes on constant expressions
  when the :code:`-fwrapv` flag is specified. You should consider setting your
  environment with :code:`CFLAGS=-fno-wrapv` or using clang (:code:`CC=clang`).

Usage
-----

Given protobuf include directories :code:`$INCLUDE`, an output directory
:code:`$OUTPUT`, and proto files :code:`$PROTO_FILES`, invoke as:

::

  $ python -m grpc_tools.protoc -I$INCLUDE --python_out=$OUTPUT --grpc_python_out=$OUTPUT $PROTO_FILES

To use as a build step in setuptools-based projects, you may use the provided
command class in your :code:`setup.py`:

::

  setuptools.setup(
    # ...
    cmdclass={
      'build_proto_modules': grpc_tools.command.BuildPackageProtos,
    }
    # ...
  )

Invocation of the command will walk the project tree and transpile every
:code:`.proto` file into a :code:`_pb2.py` file in the same directory.

Note that this particular approach requires :code:`grpcio-tools` to be
installed on the machine before the setup script is invoked (i.e. no
combination of :code:`setup_requires` or :code:`install_requires` will provide
access to :code:`grpc_tools.command.BuildPackageProtos` if it isn't already
installed). One way to work around this can be found in our
:code:`grpcio-health-checking`
`package <https://pypi.python.org/pypi/grpcio-health-checking>`_:

::

  class BuildPackageProtos(setuptools.Command):
    """Command to generate project *_pb2.py modules from proto files."""
    # ...
    def run(self):
      from grpc_tools import command
      command.build_package_protos(self.distribution.package_dir[''])

Now including :code:`grpcio-tools` in :code:`setup_requires` will provide the
command on-setup as desired.

For more information on command classes, consult :code:`setuptools` documentation.
版本列表
1.82.0rc1 2026-06-17
1.81.1 2026-06-11
1.81.0 2026-06-01
1.81.0rc1 2026-05-18
1.80.0 2026-03-30
1.80.0rc1 2026-03-17
1.78.1 2026-02-20
1.78.0 2026-02-06
1.78.0rc2 2026-01-16
1.76.0 2025-10-21
1.76.0rc1 2025-10-03
1.75.1 2025-09-26
1.75.0 2025-09-16
1.75.0rc1 2025-08-27
1.74.0 2025-07-24
1.74.0rc1 2025-07-14
1.73.1 2025-06-26
1.73.0 2025-06-09
1.73.0rc1 2025-05-28
1.72.2 2025-06-26
1.72.1 2025-06-02
1.72.0 2025-04-25
1.72.0rc1 2025-04-08
1.71.2 2025-06-28
1.71.0 2025-03-10
1.71.0rc2 2025-02-24
1.70.0 2025-01-23
1.70.0rc1 2025-01-15
1.69.0 2025-01-05
1.69.0rc1 2024-12-17
1.68.1 2024-12-02
1.68.0 2024-11-16
1.68.0rc1 2024-10-31
1.67.1 2024-10-29
1.67.0 2024-10-16
1.67.0rc1 2024-09-20
1.66.2 2024-09-28
1.66.1 2024-08-28
1.66.0 2024-08-22
1.66.0rc5 2024-08-16
1.66.0rc3 2024-08-08
1.66.0rc2 2024-08-02
1.66.0rc1 2024-08-02
1.65.5 2024-08-17
1.65.4 2024-08-02
1.65.2 2024-07-31
1.65.1 2024-07-18
1.65.0 2024-07-11
1.65.0rc2 2024-06-27
1.65.0rc1 2024-06-18
1.64.3 2024-08-06
1.64.1 2024-06-03
1.64.0 2024-05-20
1.64.0rc1 2024-05-08
1.63.2 2024-08-06
1.63.0 2024-04-30
1.63.0rc2 2024-04-19
1.63.0rc1 2024-04-15
1.62.3 2024-08-06
1.62.2 2024-04-18
1.62.1 2024-03-08
1.62.0 2024-02-21
1.62.0rc1 2024-02-16
1.61.3 2024-08-06
1.60.2 2024-08-06
1.60.1 2024-02-01
1.60.0 2023-12-07
1.60.0rc1 2023-11-14
1.59.5 2024-08-06
1.59.3 2023-11-17
1.59.2 2023-10-30
1.59.0 2023-09-29
1.59.0rc1 2023-09-27
1.58.3 2024-08-06
1.58.0 2023-09-07
1.58.0rc1 2023-08-25
1.57.0 2023-08-10
1.57.0rc1 2023-07-26
1.56.2 2023-07-19
1.56.0 2023-06-22
1.56.0rc2 2023-06-13
1.55.3 2023-08-01
1.55.0 2023-05-22
1.55.0rc1 2023-05-01
1.54.3 2023-08-02
1.54.2 2023-05-12
1.54.0 2023-04-18
1.54.0rc1 2023-04-05
1.53.2 2023-08-02
1.53.1 2023-05-12
1.53.0 2023-03-27
1.53.0rc2 2023-03-14
1.52.0 2023-02-06
1.52.0rc1 2023-01-19
1.51.3 2023-02-21
1.51.1 2022-11-29
1.51.0 2022-11-21
1.51.0rc1 2022-11-14
1.50.0 2022-10-18
1.50.0rc1 2022-10-03
1.49.1 2022-09-22
1.49.0 2022-09-15
1.49.0rc3 2022-09-01
1.49.0rc1 2022-08-18
1.48.2 2022-09-22
1.48.1 2022-09-01
1.48.0 2022-07-28
1.48.0rc1 2022-07-06
1.47.5 2023-02-28
1.47.2 2022-09-22
1.47.0 2022-06-22
1.47.0rc1 2022-06-17
1.46.5 2022-09-22
1.46.3 2022-05-20
1.46.1 2022-05-11
1.46.0 2022-05-04
1.46.0rc2 2022-04-22
1.46.0rc1 2022-04-18
1.45.0 2022-03-23
1.45.0rc1 2022-03-10
1.44.0 2022-02-17
1.44.0rc2 2022-01-28
1.44.0rc1 2022-01-24
1.43.0 2021-12-16
1.43.0rc1 2021-12-07
1.42.0 2021-11-17
1.42.0rc1 2021-11-05
1.41.1 2021-10-25
1.41.0 2021-09-27
1.41.0rc2 2021-09-20
1.40.0 2021-09-07
1.40.0rc1 2021-08-24
1.39.0 2021-07-21
1.39.0rc1 2021-07-02
1.38.1 2021-06-21
1.38.0 2021-05-20
1.38.0rc1 2021-05-11
1.37.1 2021-04-29
1.37.0 2021-04-07
1.37.0rc1 2021-03-31
1.36.1 2021-03-03
1.36.0 2021-02-26
1.36.0rc1 2021-02-16
1.35.0 2021-01-20
1.35.0rc1 2021-01-08
1.34.1 2021-01-13
1.34.0 2020-12-02
1.34.0rc1 2020-11-23
1.33.2 2020-10-28
1.33.1 2020-10-21
1.33.0rc2 2020-10-14
1.33.0rc1 2020-10-08
1.32.0 2020-09-09
1.32.0rc1 2020-08-31
1.31.0 2020-08-05
1.31.0rc2 2020-07-29
1.31.0rc1 2020-07-23
1.30.0 2020-06-23
1.30.0rc1 2020-06-08
1.29.0 2020-05-14
1.28.1 2020-04-03
1.28.0.dev0 2020-02-27
1.28.0rc3 2020-03-06
1.28.0rc2 2020-03-03
1.28.0rc1 2020-02-27
1.27.2 2020-02-13
1.27.1 2020-02-07
1.27.0rc2 2020-01-28
1.27.0rc1 2020-01-23
1.26.0 2019-12-18
1.26.0rc1 2019-12-05
1.25.0 2019-11-06
1.25.0rc1 2019-10-25
1.24.3 2019-10-23
1.24.1 2019-10-03
1.24.0 2019-09-26
1.24.0rc1 2019-09-20
1.23.1 2019-09-30
1.23.0 2019-08-16
1.23.0rc1 2019-08-05
1.22.1 2019-08-15
1.22.0 2019-07-03
1.22.0rc1 2019-06-20
1.21.1 2019-05-24
1.21.1rc1 2019-05-24
1.21.0rc1 2019-05-10
1.20.1 2019-04-26
1.20.0 2019-04-16
1.20.0rc3 2019-04-08
1.20.0rc2 2019-04-04
1.20.0rc1 2019-04-02
1.19.0 2019-02-27
1.19.0rc1 2019-02-15
1.18.0 2019-01-15
1.18.0rc1 2019-01-08
1.17.1 2018-12-13
1.17.0 2018-12-05
1.17.1rc1 2018-12-07
1.17.0rc1 2018-11-20
1.16.1 2018-11-15
1.16.0 2018-10-24
1.16.1rc1 2018-11-07
1.16.0rc1 2018-10-09
1.15.0 2018-09-12
1.15.0rc1 2018-08-28
1.14.2 2018-08-30
1.14.1 2018-08-08
1.14.0 2018-08-02
1.14.2rc1 2018-08-22
1.14.0rc2 2018-07-31
1.14.0rc1 2018-07-25
1.13.0 2018-06-29
1.13.0rc3 2018-06-25
1.13.0rc2 2018-06-16
1.13.0rc1 2018-06-11
1.12.1 2018-06-05
1.12.0 2018-05-15
1.12.0rc1 2018-05-04
1.11.1 2018-05-15
1.11.0 2018-04-13
1.11.1rc1 2018-05-03
1.11.0rc2 2018-04-10
1.11.0rc1 2018-04-06
1.10.1 2018-04-06
1.10.0 2018-03-02
1.10.1rc2 2018-04-05
1.10.1rc1 2018-03-28
1.10.0rc2 2018-02-27
1.10.0rc1 2018-02-23
1.9.1 2018-02-06
1.9.0 2018-02-02
1.9.0rc3 2018-01-30
1.9.0rc2 2018-01-25
1.8.6 2018-01-29
1.8.4 2018-01-10
1.8.3 2018-01-03
1.8.2 2017-12-20
1.8.1 2017-12-15
1.7.3 2017-12-05
1.7.0 2017-10-26
1.6.3 2017-09-28
1.6.0 2017-08-30
1.4.0 2017-06-21
1.3.5 2017-05-22
1.3.3 2017-05-22
1.3.0 2017-04-28
1.2.1 2017-03-29
1.2.0 2017-03-20
1.1.3 2017-02-24
1.1.0 2017-01-31
1.0.4 2016-12-14
1.0.3 2016-12-13
1.0.2 2016-12-10
1.0.1 2016-10-28
1.0.0 2016-08-19
0.15.1 2016-07-02
0.14.0 2016-05-10