[Python] Migrate to pyproject.toml build system (#40833)

Fixes #40744.

Closes #40833

PiperOrigin-RevId: 826625632
This commit is contained in:
Sreenithi Sridharan
2025-10-31 14:16:50 -07:00
committed by Copybara-Service
parent f7af464623
commit d8698ff717
53 changed files with 1107 additions and 684 deletions

View File

@@ -26,4 +26,3 @@ include requirements.txt
include etc/roots.pem
include Makefile
include LICENSE
include _metadata.py

View File

@@ -22,7 +22,7 @@ extend-exclude = '''
| src/python/grpcio_observability/observability_lib_deps.py
| .*_pb2.py # autogenerated Protocol Buffer files
| .*_pb2_grpc.py # autogenerated Protocol Buffer gRPC files
# AUTO-GENERATED By tools/distrib/python/xds_protos/build.py
# AUTO-GENERATED By tools/distrib/python/xds_protos/build_xds_protos.py
| tools/distrib/python/xds_protos/.*
)
'''

70
pyproject.toml Normal file
View File

@@ -0,0 +1,70 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
"cython==3.1.1"
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio"
license = "Apache-2.0"
description = "HTTP/2-based RPC framework"
readme = {file = "src/python/grpcio/README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
dynamic = [
"classifiers",
"dependencies",
"optional-dependencies",
"requires-python",
"version",
]
[project.urls]
Homepage = "https://grpc.io"
"Source Code" = "https://github.com/grpc/grpc"
"Bug Tracker" = "https://github.com/grpc/grpc/issues"
Documentation = "https://grpc.github.io/grpc/python"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages.find]
where = ["src/python/grpcio"]
[tool.setuptools.package-dir]
"" = "src/python/grpcio"
[tool.setuptools.package-data]
# Binaries that may or may not be present in the final installation, but are
# mentioned here for completeness.
"grpc._cython" = [
"_credentials/roots.pem",
"_windows/grpc_c.32.python",
"_windows/grpc_c.64.python",
]
[tool.setuptools.exclude-package-data]
# Exclude cython source and intermediate files from the .whl file
"*" = [
"*.pyx",
"*.cpp",
"*.pxd",
"*.pxi",
]

View File

@@ -47,11 +47,11 @@ opentelemetry-sdk
protobuf
pyyaml # for DNS test
requests
setuptools>=77.0.1; python_version > "3.8"
setuptools>=75.3.2; python_version <= "3.8"
# Currently our CI uses Python < 3.8, hence <4.4.1 was added
# TODO(asheshvidyut): remove the <4.4.1, when CI uses python >= 3.9
typeguard~=4.2.0,<4.4.1
typing-extensions==4.12.2
twisted # for DNS test
urllib3
setuptools>=77.0.1; python_version > "3.8"
setuptools>=75.3.2; python_version <= "3.8"

View File

@@ -1,5 +1,6 @@
# GRPC Python setup requirements
coverage>=4.0
build>=1.3.0
coverage>=7.9.0
cython==3.1.1
protobuf>=6.31.1,<7.0.0
typing-extensions==4.12.2

View File

@@ -1,6 +1,10 @@
# Setup settings for GRPC Python
[coverage:run]
# Default core on Python3.14+ has changed to sysmon which doesn't support
# plugins. So force coverage to use the C Tracer to support plugins on
# Python 3.14+
core = ctrace
plugins = Cython.Coverage
[build]
@@ -9,8 +13,5 @@ build_base=pyb
[build_ext]
inplace=1
[build_package_protos]
exclude=.*protoc_plugin/protoc_plugin_test\.proto$
[metadata]
license_files = LICENSE

View File

@@ -36,14 +36,12 @@ from subprocess import PIPE
import sys
import sysconfig
import _metadata
from setuptools import Extension
from setuptools.command import egg_info
# Redirect the manifest template from MANIFEST.in to PYTHON-MANIFEST.in.
egg_info.manifest_maker.template = "PYTHON-MANIFEST.in"
PY3 = sys.version_info.major == 3
PYTHON_STEM = os.path.join("src", "python", "grpcio")
CORE_INCLUDE = (
"include",
@@ -83,17 +81,15 @@ ZLIB_INCLUDE = (os.path.join("third_party", "zlib"),)
README = os.path.join(PYTHON_STEM, "README.rst")
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.abspath(PYTHON_STEM))
# Break import-style to ensure we can actually find our in-repo dependencies.
import _parallel_compile_patch
import _spawn_patch
import grpc_core_dependencies
import python_version
import commands
import grpc_version
import python_version
_parallel_compile_patch.monkeypatch_compile_maybe()
_spawn_patch.monkeypatch_spawn()
@@ -101,18 +97,14 @@ _spawn_patch.monkeypatch_spawn()
LICENSE = "Apache License 2.0"
CLASSIFIERS = (
[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
+ [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
+ ["License :: OSI Approved :: Apache Software License"]
)
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
] + [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
def _env_bool_value(env_name, default):
@@ -408,7 +400,7 @@ DEFINE_MACROS += (
("GRPC_XDS_USER_AGENT_NAME_SUFFIX", _quote_build_define("Python")),
(
"GRPC_XDS_USER_AGENT_VERSION_SUFFIX",
_quote_build_define(_metadata.__version__),
_quote_build_define(grpc_version.VERSION),
),
)
@@ -478,7 +470,7 @@ DEFINE_MACROS += (("__STDC_FORMAT_MACROS", None),)
LDFLAGS = tuple(EXTRA_LINK_ARGS)
CFLAGS = tuple(EXTRA_COMPILE_ARGS)
if "linux" in sys.platform or "darwin" in sys.platform:
pymodinit_type = "PyObject*" if PY3 else "void"
pymodinit_type = "PyObject*"
pymodinit = 'extern "C" __attribute__((visibility ("default"))) {}'.format(
pymodinit_type
)
@@ -544,10 +536,6 @@ def cython_extensions_and_necessity():
CYTHON_EXTENSION_MODULES, need_cython = cython_extensions_and_necessity()
PACKAGE_DIRECTORIES = {
"": PYTHON_STEM,
}
INSTALL_REQUIRES = ("typing-extensions~=4.12",)
EXTRAS_REQUIRES = {
@@ -592,40 +580,13 @@ shutil.copyfile(
os.path.join("etc", "roots.pem"), os.path.join(credentials_dir, "roots.pem")
)
PACKAGE_DATA = {
# Binaries that may or may not be present in the final installation, but are
# mentioned here for completeness.
"grpc._cython": [
"_credentials/roots.pem",
"_windows/grpc_c.32.python",
"_windows/grpc_c.64.python",
],
}
PACKAGES = setuptools.find_packages(PYTHON_STEM)
setuptools.setup(
name="grpcio",
version=grpc_version.VERSION,
description="HTTP/2-based RPC framework",
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
url="https://grpc.io",
project_urls={
"Source Code": "https://github.com/grpc/grpc",
"Bug Tracker": "https://github.com/grpc/grpc/issues",
"Documentation": "https://grpc.github.io/grpc/python",
},
license=LICENSE,
classifiers=CLASSIFIERS,
long_description_content_type="text/x-rst",
long_description=open(README).read(),
ext_modules=CYTHON_EXTENSION_MODULES,
packages=list(PACKAGES),
package_dir=PACKAGE_DIRECTORIES,
package_data=PACKAGE_DATA,
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS,
)
if __name__ == "__main__":
setuptools.setup(
classifiers=CLASSIFIERS,
ext_modules=CYTHON_EXTENSION_MODULES,
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS,
)

View File

@@ -33,9 +33,11 @@ import support
PYTHON_STEM = os.path.dirname(os.path.abspath(__file__))
GRPC_STEM = os.path.abspath(PYTHON_STEM + "../../../../")
PROTO_STEM = os.path.join(GRPC_STEM, "src", "proto")
PROTO_GEN_STEM = os.path.join(GRPC_STEM, "src", "python", "gens")
CYTHON_STEM = os.path.join(PYTHON_STEM, "grpc", "_cython")
GRPC_ROOT = os.path.relpath(GRPC_STEM, start=GRPC_STEM)
PYTHON_REL_PATH = os.path.relpath(PYTHON_STEM, start=GRPC_STEM)
PROTO_STEM = os.path.join(GRPC_ROOT, "src", "proto")
PROTO_GEN_STEM = os.path.join(GRPC_ROOT, "src", "python", "gens")
CYTHON_STEM = os.path.join(PYTHON_REL_PATH, "grpc", "_cython")
class CommandError(Exception):
@@ -101,8 +103,8 @@ class SphinxDocumentation(setuptools.Command):
# relevant package eggs first.
import sphinx.cmd.build
source_dir = os.path.join(GRPC_STEM, "doc", "python", "sphinx")
target_dir = os.path.join(GRPC_STEM, "doc", "build")
source_dir = os.path.join(GRPC_ROOT, "doc", "python", "sphinx")
target_dir = os.path.join(GRPC_ROOT, "doc", "build")
exit_code = sphinx.cmd.build.build_main(
["-b", "html", "-W", "--keep-going", source_dir, target_dir]
)
@@ -125,7 +127,9 @@ class BuildProjectMetadata(setuptools.Command):
pass
def run(self):
module_file_path = os.path.join(PYTHON_STEM, "grpc/_grpcio_metadata.py")
module_file_path = os.path.join(
PYTHON_REL_PATH, "grpc/_grpcio_metadata.py"
)
version = self.distribution.get_version()
# TODO(sergiitk): sometime in Nov 2025 - consider removing the env var
@@ -176,7 +180,11 @@ class BuildPy(build_py.build_py):
def _poison_extensions(extensions, message):
"""Includes a file that will always fail to compile in all extensions."""
poison_filename = os.path.join(PYTHON_STEM, "poison.c")
# use relative path as setuptools doesn't support absolute path in
# extension.sources
poison_filename = os.path.join(PYTHON_REL_PATH, "poison.c")
with open(poison_filename, "w") as poison:
poison.write("#error {}".format(message))
for extension in extensions:

View File

@@ -0,0 +1,47 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-admin"
license = "Apache-2.0"
description = "a collection of admin services"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
dynamic = ["dependencies", "version", "requires-python"]
[project.urls]
Homepage = "https://grpc.io"
Documentation = "https://grpc.github.io/grpc/python/grpc_admin.html"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages]
find = {}
[tool.setuptools.package-dir]
"" = "."

View File

@@ -18,27 +18,12 @@ import sys
import setuptools
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our local modules.
import python_version
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import grpc_version
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
]
PACKAGE_DIRECTORIES = {
"": ".",
}
import python_version
INSTALL_REQUIRES = (
"grpcio-channelz>={version}".format(version=grpc_version.VERSION),
@@ -46,20 +31,11 @@ INSTALL_REQUIRES = (
)
SETUP_REQUIRES = INSTALL_REQUIRES
PYTHON_REQUIRES = f">={python_version.MIN_PYTHON_VERSION}"
setuptools.setup(
name="grpcio-admin",
version=grpc_version.VERSION,
license="Apache License 2.0",
description="a collection of admin services",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
classifiers=CLASSIFIERS,
url="https://grpc.io",
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages("."),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
)
if __name__ == "__main__":
setuptools.setup(
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
)

View File

@@ -19,10 +19,10 @@ import shutil
import setuptools
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
CHANNELZ_PROTO = os.path.join(
ROOT_DIR, "../../proto/grpc/channelz/channelz.proto"
)
LICENSE = os.path.join(ROOT_DIR, "../../../LICENSE")
GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..")
ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH)
CHANNELZ_PROTO = "src/proto/grpc/channelz/channelz.proto"
LICENSE = "./LICENSE"
class Preprocess(setuptools.Command):
@@ -43,10 +43,10 @@ class Preprocess(setuptools.Command):
if os.path.isfile(CHANNELZ_PROTO):
shutil.copyfile(
CHANNELZ_PROTO,
os.path.join(ROOT_DIR, "grpc_channelz/v1/channelz.proto"),
os.path.join(ROOT_REL_DIR, "grpc_channelz/v1/channelz.proto"),
)
if os.path.isfile(LICENSE):
shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE"))
shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE"))
class BuildPackageProtos(setuptools.Command):
@@ -62,10 +62,7 @@ class BuildPackageProtos(setuptools.Command):
pass
def run(self):
# due to limitations of the proto generator, we require that only *one*
# directory is provided as an 'include' directory. We assume it's the '' key
# to `self.distribution.package_dir` (and get a key error if it's not
# there).
from grpc_tools import command
command.build_package_protos(self.distribution.package_dir[""])
# find and build all protos in the current package
command.build_package_protos(ROOT_REL_DIR)

View File

@@ -0,0 +1,42 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-channelz"
license = "Apache-2.0"
description = "Channel Level Live Debug Information Service for gRPC"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
dynamic = ["dependencies", "version", "requires-python", "classifiers"]
[project.urls]
Homepage = "https://grpc.io"
Documentation = "https://grpc.github.io/grpc/python/grpc_channelz.html"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages]
find = {}
[tool.setuptools.package-dir]
"" = "."

View File

@@ -18,16 +18,12 @@ import sys
import setuptools
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our local modules.
import python_version
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import grpc_version
import python_version
class _NoOpCommand(setuptools.Command):
@@ -46,24 +42,16 @@ class _NoOpCommand(setuptools.Command):
pass
CLASSIFIERS = (
[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
+ [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
+ ["License :: OSI Approved :: Apache Software License"]
)
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
] + [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
PACKAGE_DIRECTORIES = {
"": ".",
}
INSTALL_REQUIRES = (
"protobuf>=6.31.1,<7.0.0",
"grpcio>={version}".format(version=grpc_version.VERSION),
@@ -90,20 +78,11 @@ except ImportError:
}
setuptools.setup(
name="grpcio-channelz",
version=grpc_version.VERSION,
license="Apache License 2.0",
description="Channel Level Live Debug Information Service for gRPC",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
classifiers=CLASSIFIERS,
url="https://grpc.io",
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages("."),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS,
)
if __name__ == "__main__":
setuptools.setup(
classifiers=CLASSIFIERS,
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS,
)

View File

@@ -0,0 +1,48 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
"protobuf>=6.31.1,<7.0.0"
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-csds"
license = "Apache-2.0"
description = "xDS configuration dump library"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
dynamic = ["dependencies", "version", "requires-python"]
[project.urls]
Homepage = "https://grpc.io"
Documentation = "https://grpc.github.io/grpc/python/grpc_csds.html"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages]
find = {}
[tool.setuptools.package-dir]
"" = "."

View File

@@ -18,27 +18,12 @@ import sys
import setuptools
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our local modules.
import python_version
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import grpc_version
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
]
PACKAGE_DIRECTORIES = {
"": ".",
}
import python_version
INSTALL_REQUIRES = (
"protobuf>=6.31.1,<7.0.0",
@@ -47,19 +32,11 @@ INSTALL_REQUIRES = (
)
SETUP_REQUIRES = INSTALL_REQUIRES
setuptools.setup(
name="grpcio-csds",
version=grpc_version.VERSION,
license="Apache License 2.0",
description="xDS configuration dump library",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
classifiers=CLASSIFIERS,
url="https://grpc.io",
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages("."),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
)
PYTHON_REQUIRES = f">={python_version.MIN_PYTHON_VERSION}"
if __name__ == "__main__":
setuptools.setup(
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
)

View File

@@ -0,0 +1,48 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-csm-observability"
license = "Apache-2.0"
description = "gRPC Python CSM observability package"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
dynamic = ["dependencies", "version", "requires-python"]
[project.urls]
Homepage = "https://grpc.io"
"Source Code" = "https://github.com/grpc/grpc/tree/master/src/python/grpcio_csm_observability"
"Bug Tracker" = "https://github.com/grpc/grpc/issues"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages]
find = {}
[tool.setuptools.package-dir]
"" = "."

View File

@@ -13,29 +13,16 @@
# limitations under the License.
import os
import sys
import setuptools
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
import python_version
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import grpc_version
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
]
PACKAGE_DIRECTORIES = {
"": ".",
}
import python_version
INSTALL_REQUIRES = (
"opentelemetry-sdk>=1.25.0",
@@ -44,22 +31,8 @@ INSTALL_REQUIRES = (
"protobuf>=6.31.1,<7.0.0",
)
setuptools.setup(
name="grpcio-csm-observability",
version=grpc_version.VERSION,
description="gRPC Python CSM observability package",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
url="https://grpc.io",
project_urls={
"Source Code": "https://github.com/grpc/grpc/tree/master/src/python/grpcio_csm_observability",
"Bug Tracker": "https://github.com/grpc/grpc/issues",
},
license="Apache License 2.0",
classifiers=CLASSIFIERS,
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages("."),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
)
if __name__ == "__main__":
setuptools.setup(
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
)

View File

@@ -19,8 +19,10 @@ import shutil
import setuptools
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
HEALTH_PROTO = os.path.join(ROOT_DIR, "../../proto/grpc/health/v1/health.proto")
LICENSE = os.path.join(ROOT_DIR, "../../../LICENSE")
GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..")
ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH)
HEALTH_PROTO = "src/proto/grpc/health/v1/health.proto"
LICENSE = "./LICENSE"
class Preprocess(setuptools.Command):
@@ -41,10 +43,10 @@ class Preprocess(setuptools.Command):
if os.path.isfile(HEALTH_PROTO):
shutil.copyfile(
HEALTH_PROTO,
os.path.join(ROOT_DIR, "grpc_health/v1/health.proto"),
os.path.join(ROOT_REL_DIR, "grpc_health/v1/health.proto"),
)
if os.path.isfile(LICENSE):
shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE"))
shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE"))
class BuildPackageProtos(setuptools.Command):
@@ -60,10 +62,7 @@ class BuildPackageProtos(setuptools.Command):
pass
def run(self):
# due to limitations of the proto generator, we require that only *one*
# directory is provided as an 'include' directory. We assume it's the '' key
# to `self.distribution.package_dir` (and get a key error if it's not
# there).
from grpc_tools import command
command.build_package_protos(self.distribution.package_dir[""])
# find and build all protos in the current package
command.build_package_protos(ROOT_REL_DIR)

View File

@@ -0,0 +1,42 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-health-checking"
license = "Apache-2.0"
description = "Standard Health Checking Service for gRPC"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
dynamic = ["dependencies", "version", "requires-python", "classifiers"]
[project.urls]
Homepage = "https://grpc.io"
Documentation = "https://grpc.github.io/grpc/python/grpc_health_checking.html"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages]
find = {}
[tool.setuptools.package-dir]
"" = "."

View File

@@ -14,19 +14,16 @@
"""Setup module for the GRPC Python package's optional health checking."""
import os
import sys
import setuptools
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our local modules.
import python_version
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import grpc_version
import python_version
class _NoOpCommand(setuptools.Command):
@@ -45,22 +42,14 @@ class _NoOpCommand(setuptools.Command):
pass
CLASSIFIERS = (
[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
+ [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
+ ["License :: OSI Approved :: Apache Software License"]
)
PACKAGE_DIRECTORIES = {
"": ".",
}
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
] + [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
INSTALL_REQUIRES = (
"protobuf>=6.31.1,<7.0.0",
@@ -87,20 +76,11 @@ except ImportError:
"build_package_protos": _NoOpCommand,
}
setuptools.setup(
name="grpcio-health-checking",
version=grpc_version.VERSION,
description="Standard Health Checking Service for gRPC",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
url="https://grpc.io",
license="Apache License 2.0",
classifiers=CLASSIFIERS,
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages("."),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS,
)
if __name__ == "__main__":
setuptools.setup(
classifiers=CLASSIFIERS,
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS,
)

View File

@@ -0,0 +1,53 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
"Cython==3.1.1",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-observability"
license = "Apache-2.0"
description = "gRPC Python observability package"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
dynamic = ["dependencies", "version", "requires-python"]
[project.urls]
Homepage = "https://grpc.io"
"Source Code" = "https://github.com/grpc/grpc/tree/master/src/python/grpcio_observability"
"Bug Tracker" = "https://github.com/grpc/grpc/issues"
Documentation = "https://grpc.github.io/grpc/python/grpc_observability.html"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages.find]
where = ["."]
# Exclude .py files like `third_party/abseil-cpp/absl/copts/copts.py` in
# `third_party` directory from being included in the wheel
exclude = [
"third_party*",
"grpc_root*",
]

View File

@@ -26,26 +26,18 @@ import setuptools
from setuptools import Extension
from setuptools.command import build_ext
PYTHON_STEM = os.path.realpath(os.path.dirname(__file__))
README_PATH = os.path.join(PYTHON_STEM, "README.rst")
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import _parallel_compile_patch
import observability_lib_deps
import python_version
import grpc_version
import python_version
_parallel_compile_patch.monkeypatch_compile_maybe()
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
]
O11Y_CC_SRCS = [
"client_call_tracer.cc",
@@ -286,32 +278,14 @@ def extension_modules():
return extensions
PACKAGES = setuptools.find_packages(PYTHON_STEM)
setuptools.setup(
name="grpcio-observability",
version=grpc_version.VERSION,
description="gRPC Python observability package",
long_description_content_type="text/x-rst",
long_description=open(README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
url="https://grpc.io",
project_urls={
"Source Code": "https://github.com/grpc/grpc/tree/master/src/python/grpcio_observability",
"Bug Tracker": "https://github.com/grpc/grpc/issues",
},
license="Apache License 2.0",
classifiers=CLASSIFIERS,
ext_modules=extension_modules(),
packages=list(PACKAGES),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=[
"grpcio=={version}".format(version=grpc_version.VERSION),
"setuptools>=77.0.1",
"opentelemetry-api>=1.21.0",
],
cmdclass={
"build_ext": BuildExt,
},
)
if __name__ == "__main__":
setuptools.setup(
ext_modules=extension_modules(),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=[
"grpcio=={version}".format(version=grpc_version.VERSION),
"setuptools>=77.0.1",
"opentelemetry-api>=1.21.0",
],
cmdclass={"build_ext": BuildExt},
)

View File

@@ -0,0 +1,42 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-reflection"
license = "Apache-2.0"
description = "Standard Protobuf Reflection Service for gRPC"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
dynamic = ["dependencies", "version", "requires-python", "classifiers"]
[project.urls]
Homepage = "https://grpc.io"
Documentation = "https://grpc.github.io/grpc/python/grpc_reflection.html"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages]
find = {}
[tool.setuptools.package-dir]
"" = "."

View File

@@ -19,10 +19,10 @@ import shutil
import setuptools
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
REFLECTION_PROTO = os.path.join(
ROOT_DIR, "../../proto/grpc/reflection/v1alpha/reflection.proto"
)
LICENSE = os.path.join(ROOT_DIR, "../../../LICENSE")
GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..")
ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH)
REFLECTION_PROTO = "src/proto/grpc/reflection/v1alpha/reflection.proto"
LICENSE = "./LICENSE"
class Preprocess(setuptools.Command):
@@ -44,11 +44,11 @@ class Preprocess(setuptools.Command):
shutil.copyfile(
REFLECTION_PROTO,
os.path.join(
ROOT_DIR, "grpc_reflection/v1alpha/reflection.proto"
ROOT_REL_DIR, "grpc_reflection/v1alpha/reflection.proto"
),
)
if os.path.isfile(LICENSE):
shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE"))
shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE"))
class BuildPackageProtos(setuptools.Command):
@@ -64,10 +64,7 @@ class BuildPackageProtos(setuptools.Command):
pass
def run(self):
# due to limitations of the proto generator, we require that only *one*
# directory is provided as an 'include' directory. We assume it's the '' key
# to `self.distribution.package_dir` (and get a key error if it's not
# there).
from grpc_tools import command
command.build_package_protos(self.distribution.package_dir[""])
# find and build all protos in the current package
command.build_package_protos(ROOT_REL_DIR)

View File

@@ -18,16 +18,12 @@ import sys
import setuptools
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our local modules.
import python_version
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import grpc_version
import python_version
class _NoOpCommand(setuptools.Command):
@@ -46,22 +42,15 @@ class _NoOpCommand(setuptools.Command):
pass
CLASSIFIERS = (
[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
+ [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
+ ["License :: OSI Approved :: Apache Software License"]
)
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
] + [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
PACKAGE_DIRECTORIES = {
"": ".",
}
INSTALL_REQUIRES = (
"protobuf>=6.31.1,<7.0.0",
@@ -88,20 +77,11 @@ except ImportError:
"build_package_protos": _NoOpCommand,
}
setuptools.setup(
name="grpcio-reflection",
version=grpc_version.VERSION,
license="Apache License 2.0",
description="Standard Protobuf Reflection Service for gRPC",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
classifiers=CLASSIFIERS,
url="https://grpc.io",
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages("."),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS,
)
if __name__ == "__main__":
setuptools.setup(
classifiers=CLASSIFIERS,
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS,
)

View File

@@ -0,0 +1,42 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-status"
license = "Apache-2.0"
description = "Status proto mapping for gRPC"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
dynamic = ["dependencies", "version", "requires-python", "classifiers"]
[project.urls]
Homepage = "https://grpc.io"
Documentation = "https://grpc.github.io/grpc/python/grpc_status.html"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages]
find = {}
[tool.setuptools.package-dir]
"" = "."

View File

@@ -14,19 +14,17 @@
"""Setup module for the GRPC Python package's status mapping."""
import os
import sys
import setuptools
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our local modules.
import python_version
import grpc_version
import python_version
class _NoOpCommand(setuptools.Command):
@@ -45,22 +43,15 @@ class _NoOpCommand(setuptools.Command):
pass
CLASSIFIERS = (
[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
+ [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
+ ["License :: OSI Approved :: Apache Software License"]
)
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
] + [
f"Programming Language :: Python :: {x}"
for x in python_version.SUPPORTED_PYTHON_VERSIONS
]
PACKAGE_DIRECTORIES = {
"": ".",
}
INSTALL_REQUIRES = (
"protobuf>=6.31.1,<7.0.0",
@@ -84,19 +75,10 @@ except ImportError:
"build_package_protos": _NoOpCommand,
}
setuptools.setup(
name="grpcio-status",
version=grpc_version.VERSION,
description="Status proto mapping for gRPC",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
url="https://grpc.io",
license="Apache License 2.0",
classifiers=CLASSIFIERS,
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages("."),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
cmdclass=COMMAND_CLASS,
)
if __name__ == "__main__":
setuptools.setup(
classifiers=CLASSIFIERS,
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
cmdclass=COMMAND_CLASS,
)

View File

@@ -19,11 +19,11 @@ import shutil
import setuptools
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
STATUS_PROTO = os.path.join(
ROOT_DIR, "../../../third_party/googleapis/google/rpc/status.proto"
)
PACKAGE_STATUS_PROTO_PATH = "grpc_status/google/rpc"
LICENSE = os.path.join(ROOT_DIR, "../../../LICENSE")
GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..")
ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH)
STATUS_PROTO = "third_party/googleapis/google/rpc/status.proto"
PACKAGE_STATUS_PROTO_DIR = "grpc_status/google/rpc"
LICENSE = "./LICENSE"
class Preprocess(setuptools.Command):
@@ -39,14 +39,16 @@ class Preprocess(setuptools.Command):
pass
def run(self):
package_status_proto_rel_path = os.path.join(
ROOT_REL_DIR, PACKAGE_STATUS_PROTO_DIR
)
if os.path.isfile(STATUS_PROTO):
if not os.path.isdir(PACKAGE_STATUS_PROTO_PATH):
os.makedirs(PACKAGE_STATUS_PROTO_PATH)
if not os.path.isdir(package_status_proto_rel_path):
os.makedirs(package_status_proto_rel_path)
shutil.copyfile(
STATUS_PROTO,
os.path.join(
ROOT_DIR, PACKAGE_STATUS_PROTO_PATH, "status.proto"
),
os.path.join(package_status_proto_rel_path, "status.proto"),
)
if os.path.isfile(LICENSE):
shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE"))
shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE"))

View File

@@ -1,4 +1,5 @@
include grpc_version.py
include python_version.py
recursive-include grpc_testing *.py
global-exclude *.pyc
include LICENSE

View File

@@ -0,0 +1,42 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-testing"
license = "Apache-2.0"
description = "Testing utilities for gRPC Python"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
dynamic = ["dependencies", "requires-python", "version", "classifiers"]
[project.urls]
Homepage = "https://grpc.io"
Documentation = "https://grpc.github.io/grpc/python/grpc_testing.html"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages]
find = {}
[tool.setuptools.package-dir]
"" = "."

View File

@@ -1,4 +1,4 @@
# Copyright 2021 The gRPC authors.
# Copyright 2024 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# AUTO-GENERATED FROM `$REPO_ROOT/templates/_metadata.py.template`!!!
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/python_version.py.template`!!!
__version__ = """{{settings.python_version.pep440}}"""
SUPPORTED_PYTHON_VERSIONS = ["3.9","3.10","3.11","3.12","3.13","3.14"]
MIN_PYTHON_VERSION = 3.9
MAX_PYTHON_VERSION = 3.14

View File

@@ -18,14 +18,13 @@ import sys
import setuptools
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
# Break import style to ensure that we can find same-directory modules.
import grpc_version
import python_version
class _NoOpCommand(setuptools.Command):
@@ -44,10 +43,6 @@ class _NoOpCommand(setuptools.Command):
pass
PACKAGE_DIRECTORIES = {
"": ".",
}
INSTALL_REQUIRES = (
"protobuf>=6.31.1,<7.0.0",
"grpcio>={version}".format(version=grpc_version.VERSION),
@@ -67,17 +62,15 @@ except ImportError:
"preprocess": _NoOpCommand,
}
setuptools.setup(
name="grpcio-testing",
version=grpc_version.VERSION,
license="Apache License 2.0",
description="Testing utilities for gRPC Python",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
url="https://grpc.io",
package_dir=PACKAGE_DIRECTORIES,
packages=setuptools.find_packages("."),
install_requires=INSTALL_REQUIRES,
cmdclass=COMMAND_CLASS,
)
CLASSIFIERS = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
if __name__ == "__main__":
setuptools.setup(
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
cmdclass=COMMAND_CLASS,
classifiers=CLASSIFIERS,
)

View File

@@ -19,7 +19,9 @@ import shutil
import setuptools
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
LICENSE = os.path.join(ROOT_DIR, "../../../LICENSE")
GRPC_ROOT_ABS_PATH = os.path.join(ROOT_DIR, "../../..")
ROOT_REL_DIR = os.path.relpath(ROOT_DIR, start=GRPC_ROOT_ABS_PATH)
LICENSE = "./LICENSE"
class Preprocess(setuptools.Command):
@@ -36,4 +38,4 @@ class Preprocess(setuptools.Command):
def run(self):
if os.path.isfile(LICENSE):
shutil.copyfile(LICENSE, os.path.join(ROOT_DIR, "LICENSE"))
shutil.copyfile(LICENSE, os.path.join(ROOT_REL_DIR, "LICENSE"))

View File

@@ -31,9 +31,10 @@ from setuptools.command import test
PYTHON_STEM = os.path.dirname(os.path.abspath(__file__))
GRPC_STEM = os.path.abspath(PYTHON_STEM + "../../../../")
GRPC_PROTO_STEM = os.path.join(GRPC_STEM, "src", "proto")
PROTO_STEM = os.path.join(PYTHON_STEM, "src", "proto")
PYTHON_PROTO_TOP_LEVEL = os.path.join(PYTHON_STEM, "src")
PYTHON_REL_PATH = os.path.relpath(PYTHON_STEM, start=GRPC_STEM)
GRPC_PROTO_STEM = os.path.join("src", "proto")
PROTO_STEM = os.path.join(PYTHON_REL_PATH, "src", "proto")
PYTHON_PROTO_TOP_LEVEL = os.path.join(PYTHON_REL_PATH, "src")
class CommandError(object):
@@ -75,6 +76,25 @@ class BuildPy(build_py.build_py):
build_py.build_py.run(self)
class BuildPackageProtos(setuptools.Command):
"""Command to generate project *_pb2.py modules from proto files."""
description = "build grpc protobuf modules"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from grpc_tools import command
# find and build all protos in the current package
command.build_package_protos(PYTHON_REL_PATH)
class TestLite(setuptools.Command):
"""Command to run tests without fetching or building anything."""

View File

@@ -0,0 +1,72 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-tests"
license = "Apache-2.0"
dynamic = [
"classifiers",
"dependencies",
"optional-dependencies",
"requires-python",
"version"
]
[project.urls]
Homepage = "https://grpc.io"
[tool.setuptools.packages]
find = {}
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.package-dir]
"" = "."
[tool.setuptools.package-data]
"tests.interop" = [
"credentials/ca.pem",
"credentials/server1.key",
"credentials/server1.pem",
]
"tests.protoc_plugin.protos.invocation_testing" = [
"same.proto",
"compiler.proto",
]
"tests.protoc_plugin.protos.invocation_testing.split_messages" = [
"messages.proto",
]
"tests.protoc_plugin.protos.invocation_testing.split_services" = [
"services.proto",
]
"tests.testing.proto" = [
"requests.proto",
"services.proto",
]
"tests.unit" = [
"credentials/ca.pem",
"credentials/server1.key",
"credentials/server1.pem",
]
"tests" = ["tests.json"]

View File

@@ -1,4 +1,4 @@
# Copyright 2021 The gRPC authors.
# Copyright 2024 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# AUTO-GENERATED FROM `$REPO_ROOT/templates/_metadata.py.template`!!!
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/python_version.py.template`!!!
__version__ = """1.77.0.dev0"""
SUPPORTED_PYTHON_VERSIONS = ["3.9","3.10","3.11","3.12","3.13","3.14"]
MIN_PYTHON_VERSION = 3.9
MAX_PYTHON_VERSION = 3.14

View File

@@ -15,29 +15,21 @@
import multiprocessing
import os
import os.path
import sys
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import grpc_tools.command
import setuptools
PY3 = sys.version_info.major == 3
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our in-repo dependencies.
import commands
import grpc_version
LICENSE = "Apache License 2.0"
PACKAGE_DIRECTORIES = {
"": ".",
}
import python_version
INSTALL_REQUIRES = (
"coverage>=4.0",
"coverage>=7.9.0",
"grpcio>={version}".format(version=grpc_version.VERSION),
"grpcio-channelz>={version}".format(version=grpc_version.VERSION),
"grpcio-status>={version}".format(version=grpc_version.VERSION),
@@ -55,7 +47,7 @@ INSTALL_REQUIRES = (
COMMAND_CLASS = {
# Run `preprocess` *before* doing any packaging!
"preprocess": commands.GatherProto,
"build_package_protos": grpc_tools.command.BuildPackageProtos,
"build_package_protos": commands.BuildPackageProtos,
"build_py": commands.BuildPy,
"run_fork": commands.RunFork,
"run_interop": commands.RunInterop,
@@ -64,52 +56,23 @@ COMMAND_CLASS = {
"test_py3_only": commands.TestPy3Only,
}
PACKAGE_DATA = {
"tests.interop": [
"credentials/ca.pem",
"credentials/server1.key",
"credentials/server1.pem",
],
"tests.protoc_plugin.protos.invocation_testing": [
"same.proto",
"compiler.proto",
],
"tests.protoc_plugin.protos.invocation_testing.split_messages": [
"messages.proto",
],
"tests.protoc_plugin.protos.invocation_testing.split_services": [
"services.proto",
],
"tests.testing.proto": [
"requests.proto",
"services.proto",
],
"tests.unit": [
"credentials/ca.pem",
"credentials/server1.key",
"credentials/server1.pem",
],
"tests": ["tests.json"],
}
TEST_SUITE = "tests"
TEST_LOADER = "tests:Loader"
TEST_RUNNER = "tests:Runner"
TESTS_REQUIRE = INSTALL_REQUIRES
PACKAGES = setuptools.find_packages(".")
CLASSIFIERS = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
if __name__ == "__main__":
multiprocessing.freeze_support()
setuptools.setup(
name="grpcio-tests",
version=grpc_version.VERSION,
license=LICENSE,
packages=list(PACKAGES),
package_dir=PACKAGE_DIRECTORIES,
package_data=PACKAGE_DATA,
install_requires=INSTALL_REQUIRES,
cmdclass=COMMAND_CLASS,
classifiers=CLASSIFIERS,
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
tests_require=TESTS_REQUIRE,
test_suite=TEST_SUITE,
test_loader=TEST_LOADER,

View File

@@ -0,0 +1,20 @@
# Copyright 2024 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/python_version.py.template`!!!
SUPPORTED_PYTHON_VERSIONS = {{settings.supported_python_versions}}
MIN_PYTHON_VERSION = {{settings.min_python_version}}
MAX_PYTHON_VERSION = {{settings.max_python_version}}

View File

@@ -0,0 +1,20 @@
# Copyright 2024 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/python_version.py.template`!!!
SUPPORTED_PYTHON_VERSIONS = {{settings.supported_python_versions}}
MIN_PYTHON_VERSION = {{settings.min_python_version}}
MAX_PYTHON_VERSION = {{settings.max_python_version}}

View File

@@ -96,7 +96,7 @@ if [[ "${GRPC_GENERATE_PROJECTS_SKIP_XDS_PROTOS:-0}" != "1" ]]; then
"${VENV_PIP}" list
echo "[gRPC Python] Generating xds-protos"
"${VENV_PYTHON}" tools/distrib/python/xds_protos/build.py
"${VENV_PYTHON}" tools/distrib/python/xds_protos/build_xds_protos.py
fi
echo "[gRPC Python] Making other grpcio auxilary packages"

View File

@@ -23,9 +23,14 @@ set -ex
HOME="$(mktemp -d)"
export HOME
SOURCE_DIR="doc/python/sphinx"
TARGET_DIR="doc/build"
pip install -r tools/distrib/docgen/requirements.docs.lock
tools/run_tests/run_tests.py -c opt -l python --compiler python3.9 --newline_on_success -j 8 --build_only
# shellcheck disable=SC1091
source py39/bin/activate
pip install --upgrade Sphinx
python setup.py doc
# Use direct sphinx-build CLI command instead of `python setup.py doc`
sphinx-build -b html -W --keep-going "$SOURCE_DIR" "$TARGET_DIR"

View File

@@ -23,13 +23,14 @@ cd "$BASEDIR";
# unit-tests setup starts from here
function maybe_run_command () {
# TODO(ssreenithi): find pyproject.toml/nox equivalent
if python3 setup.py --help-commands | grep "$1" &>/dev/null; then
python3 setup.py "$1";
fi
}
python3 -m pip install --upgrade "cython==3.1.1";
python3 setup.py install;
python3 -m pip install .;
# Build and install grpcio_tools
pushd tools/distrib/python/grpcio_tools;

View File

@@ -41,25 +41,24 @@ def _get_resource_file_name(
def build_package_protos(package_root, strict_mode=False):
proto_files = []
inclusion_root = os.path.abspath(package_root)
for root, _, files in os.walk(inclusion_root):
for root, _, files in os.walk(package_root):
for filename in files:
if filename.endswith(".proto"):
proto_files.append(
os.path.abspath(os.path.join(root, filename))
)
proto_files.append(os.path.join(root, filename))
well_known_protos_include = _get_resource_file_name("grpc_tools", "_proto")
for proto_file in proto_files:
command = [
"grpc_tools.protoc",
"--proto_path={}".format(inclusion_root),
"--proto_path={}".format(package_root),
"--proto_path={}".format(well_known_protos_include),
"--python_out={}".format(inclusion_root),
"--pyi_out={}".format(inclusion_root),
"--grpc_python_out={}".format(inclusion_root),
"--python_out={}".format(package_root),
"--pyi_out={}".format(package_root),
"--grpc_python_out={}".format(package_root),
] + [proto_file]
if protoc.main(command) != 0:
if strict_mode:

View File

@@ -0,0 +1,65 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
"Cython==3.1.1",
]
build-backend = "setuptools.build_meta"
[project]
name = "grpcio-tools"
license = "Apache-2.0"
description = "Protobuf code generator for gRPC"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
dynamic = ["dependencies", "version", "requires-python"]
[project.urls]
Homepage = "https://grpc.io"
"Source Code" = "https://github.com/grpc/grpc/tree/master/tools/distrib/python/grpcio_tools"
"Bug Tracker" = "https://github.com/grpc/grpc/issues"
[project.scripts]
"python-grpc-tools-protoc" = "grpc_tools.protoc:entrypoint"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages.find]
where = ["."]
# Exclude .py files like `third_party/abseil-cpp/absl/copts/copts.py` in
# `third_party` directory from being included in the wheel
exclude = [
"dist*",
"grpc_root*",
"third_party*",
]
[tool.setuptools.exclude-package-data]
# Exclude cython source and intermediate files from the .whl file
"*" = [
"*.pyx",
"*.cpp",
"*.cc",
"*.h",
]

View File

@@ -31,37 +31,21 @@ from setuptools.command import build_ext
# TODO(atash) add flag to disable Cython use
_PACKAGE_PATH = os.path.realpath(os.path.dirname(__file__))
_README_PATH = os.path.join(_PACKAGE_PATH, "README.rst")
os.chdir(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.abspath("."))
import _parallel_compile_patch
import _spawn_patch
import protoc_lib_deps
import python_version
import grpc_version
import python_version
_EXT_INIT_SYMBOL = None
if sys.version_info[0] == 2:
_EXT_INIT_SYMBOL = "init_protoc_compiler"
else:
_EXT_INIT_SYMBOL = "PyInit__protoc_compiler"
_EXT_INIT_SYMBOL = "PyInit__protoc_compiler"
_parallel_compile_patch.monkeypatch_compile_maybe()
_spawn_patch.monkeypatch_spawn()
CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
]
PY3 = sys.version_info.major == 3
def _env_bool_value(env_name, default):
"""Parses a bool option from an environment variable"""
@@ -343,36 +327,17 @@ def extension_modules():
return extensions
setuptools.setup(
name="grpcio-tools",
version=grpc_version.VERSION,
description="Protobuf code generator for gRPC",
long_description_content_type="text/x-rst",
long_description=open(_README_PATH, "r").read(),
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
url="https://grpc.io",
project_urls={
"Source Code": "https://github.com/grpc/grpc/tree/master/tools/distrib/python/grpcio_tools",
"Bug Tracker": "https://github.com/grpc/grpc/issues",
},
license="Apache License 2.0",
classifiers=CLASSIFIERS,
ext_modules=extension_modules(),
packages=setuptools.find_packages("."),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=[
"protobuf>=6.31.1,<7.0.0",
"grpcio>={version}".format(version=grpc_version.VERSION),
"setuptools>=77.0.1",
],
package_data=package_data(),
cmdclass={
"build_ext": BuildExt,
},
entry_points={
"console_scripts": [
"python-grpc-tools-protoc = grpc_tools.protoc:entrypoint",
if __name__ == "__main__":
setuptools.setup(
ext_modules=extension_modules(),
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=[
"protobuf>=6.31.1,<7.0.0",
"grpcio>={version}".format(version=grpc_version.VERSION),
"setuptools>=77.0.1",
],
},
)
package_data=package_data(),
cmdclass={
"build_ext": BuildExt,
},
)

View File

@@ -58,15 +58,14 @@ EXCLUDE_PROTO_PACKAGES_LIST = tuple(
# Compute the paths
WORK_DIR = os.path.dirname(os.path.abspath(__file__))
GRPC_ROOT = os.path.abspath(os.path.join(WORK_DIR, "..", "..", "..", ".."))
ENVOY_API_PROTO_ROOT = os.path.join(GRPC_ROOT, "third_party", "envoy-api")
XDS_PROTO_ROOT = os.path.join(GRPC_ROOT, "third_party", "xds")
GOOGLEAPIS_ROOT = os.path.join(GRPC_ROOT, "third_party", "googleapis")
VALIDATE_ROOT = os.path.join(GRPC_ROOT, "third_party", "protoc-gen-validate")
ENVOY_API_PROTO_ROOT = os.path.join("third_party", "envoy-api")
XDS_PROTO_ROOT = os.path.join("third_party", "xds")
GOOGLEAPIS_ROOT = os.path.join("third_party", "googleapis")
VALIDATE_ROOT = os.path.join("third_party", "protoc-gen-validate")
OPENCENSUS_PROTO_ROOT = os.path.join(
GRPC_ROOT, "third_party", "opencensus-proto", "src"
"third_party", "opencensus-proto", "src"
)
OPENTELEMETRY_PROTO_ROOT = os.path.join(GRPC_ROOT, "third_party", "opentelemetry")
OPENTELEMETRY_PROTO_ROOT = os.path.join("third_party", "opentelemetry")
WELL_KNOWN_PROTOS_INCLUDE = _get_resource_file_name("grpc_tools", "_proto")
OUTPUT_PATH = WORK_DIR

View File

@@ -0,0 +1,50 @@
# Copyright 2025 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[build-system]
requires = [
"setuptools>=77.0.1",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "xds-protos"
license = "Apache-2.0"
description = "Generated Python code from envoyproxy/data-plane-api"
readme = {file = "README.rst", content-type = "text/x-rst"}
authors = [{name = "The gRPC Authors", email = "grpc-io@googlegroups.com"}]
classifiers = [
"Development Status :: 3 - Alpha",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
]
dynamic = ["dependencies", "version", "requires-python"]
[project.urls]
Homepage = "https://grpc.io"
[tool.setuptools.dynamic]
version = {attr = "grpc_version.VERSION"}
[tool.setuptools.packages.find]
where = ["."]
exclude = [
"generated_file_import_test.py",
"build_xds_protos.py",
"dist*",
"bazel*",
"contrib*"
]

View File

@@ -17,27 +17,15 @@
import os
import setuptools
import sys
# Manually insert the source directory into the Python path for local module
# imports to succeed
sys.path.insert(0, os.path.abspath("."))
import grpc_version
import python_version
WORK_DIR = os.path.dirname(os.path.abspath(__file__))
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(WORK_DIR)
EXCLUDE_PYTHON_FILES = ["generated_file_import_test.py", "build.py"]
# Use setuptools to build Python package
with open(os.path.join(WORK_DIR, "README.rst"), "r") as f:
LONG_DESCRIPTION = f.read()
PACKAGES = setuptools.find_packages(where=".", exclude=EXCLUDE_PYTHON_FILES)
CLASSIFIERS = [
"Development Status :: 3 - Alpha",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
]
# Keep this in sync with XDS_PROTOS_GENCODE_GRPC_VERSION
# in tools/buildgen/generate_projects.sh.
@@ -51,19 +39,9 @@ SETUP_REQUIRES = INSTALL_REQUIRES + [
f"grpcio-tools>={XDS_PROTOS_GENCODE_GRPC_VERSION}"
]
setuptools.setup(
name="xds-protos",
version=grpc_version.VERSION,
packages=PACKAGES,
description="Generated Python code from envoyproxy/data-plane-api",
long_description_content_type="text/x-rst",
long_description=LONG_DESCRIPTION,
author="The gRPC Authors",
author_email="grpc-io@googlegroups.com",
url="https://grpc.io",
license="Apache License 2.0",
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
classifiers=CLASSIFIERS,
)
if __name__ == "__main__":
setuptools.setup(
python_requires=f">={python_version.MIN_PYTHON_VERSION}",
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
)

View File

@@ -27,7 +27,7 @@ source tools/internal_ci/helper_scripts/prepare_build_linux_rc
source tools/internal_ci/helper_scripts/prepare_ccache_rc
# Build all python linux artifacts (this step actually builds all the binary wheels and source archives)
tools/run_tests/task_runner.py -f artifact linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x build_artifacts/sponge_log.xml || FAILED="true"
tools/run_tests/task_runner.py -f artifact linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x build_artifacts/sponge_log.xml || BUILD_ARTIFACT_FAILED="true"
# the next step expects to find the artifacts from the previous step in the "input_artifacts" folder.
rm -rf input_artifacts
@@ -51,10 +51,12 @@ rm -rf input_artifacts
mkdir -p input_artifacts
cp -r artifacts/* input_artifacts/ || true
# Run all python linux distribtests
# We run the distribtests even if some of the artifacts have failed to build, since that gives
# a better signal about which distribtest are affected by the currently broken artifact builds.
# exit early if build_artifact or package task fails, for faster test run time
if [[ "$BUILD_ARTIFACT_FAILED" != "" || "$FAILED" != "" ]]; then
exit 1
fi
# Run all python linux distribtests
tools/run_tests/task_runner.py -f distribtest linux python ${TASK_RUNNER_EXTRA_FILTERS} -j 12 -x distribtests/sponge_log.xml || FAILED="true"

View File

@@ -23,7 +23,7 @@ python -m pip install --upgrade pip==25.2 six
@rem Ping to a single version to make sure we're building the same artifacts
python -m pip install setuptools==77.0.1 wheel==0.43.0
python -m pip install --upgrade "cython==3.1.1"
python -m pip install -rrequirements.txt --user
python -m pip install -r requirements.txt --user
@rem set GRPC_PYTHON_OVERRIDE_CYGWIN_DETECTION_FOR_27=1
set GRPC_PYTHON_BUILD_WITH_CYTHON=1
@@ -38,26 +38,20 @@ if "%GRPC_PYTHON_BUILD_EXT_COMPILER_JOBS%"=="" (
mkdir -p %ARTIFACTS_OUT%
set ARTIFACT_DIR=%cd%\%ARTIFACTS_OUT%
@rem use short temp directory to avoid linker command file errors caused by
@rem exceeding 131071 characters.
@rem TODO(ssreenithi): Remove once we have a better solution: b/454497076
set "GRPC_PYTHON_BUILD_USE_SHORT_TEMP_DIR_NAME=1"
@rem Build gRPC Python extensions
python setup.py build_ext -c %EXT_COMPILER% || goto :error
@rem Build gRPC Python distribution
python -m build || goto :error
@rem Set up and build gRPC Python tools
@rem Set up gRPC Python tools
python tools\distrib\python\make_grpcio_tools.py
@rem Build grpcio-tools Python distribution
pushd tools\distrib\python\grpcio_tools
python setup.py build_ext -c %EXT_COMPILER% || goto :error
popd
@rem Build gRPC Python distributions
python setup.py bdist_wheel || goto :error
pushd tools\distrib\python\grpcio_tools
python setup.py bdist_wheel || goto :error
python -m build || goto :error
popd
@rem Ensure the generate artifacts are valid.

View File

@@ -28,7 +28,7 @@ source tools/internal_ci/helper_scripts/prepare_ccache_symlinks_rc
# Needed for building binary distribution wheels -- bdist_wheel
"${PYTHON}" -m pip install --upgrade pip==25.2
# Ping to a single version to make sure we're building the same artifacts
"${PYTHON}" -m pip install setuptools==77.0.1 wheel==0.43.0
"${PYTHON}" -m pip install setuptools==77.0.1 wheel==0.43.0 build==1.3.0
if [ "$GRPC_SKIP_PIP_CYTHON_UPGRADE" == "" ]
then
@@ -100,15 +100,17 @@ for directory in "${ancillary_package_dir[@]}"; do
cp "LICENSE" "${directory}"
done
# Build the source distribution first because MANIFEST.in cannot override
# exclusion of built shared objects among package resources (for some
# inexplicable reason).
${SETARCH_CMD} "${PYTHON}" setup.py sdist
# Set build config option with WHEEL_PLAT_NAME_FLAG if it exists
WHEEL_PLAT_CONFIG_OPTION=()
if [[ -n "$WHEEL_PLAT_NAME_FLAG" ]]; then
WHEEL_PLAT_CONFIG_OPTION+=("-C--build-option=\"$WHEEL_PLAT_NAME_FLAG\"")
fi
# Wheel has a bug where directories don't get excluded.
# https://bitbucket.org/pypa/wheel/issues/99/cannot-exclude-directory
# shellcheck disable=SC2086
${SETARCH_CMD} "${PYTHON}" setup.py bdist_wheel $WHEEL_PLAT_NAME_FLAG
# Build without setting explicit flags like --sdist or --wheel so that `build`
# package first builds the sdist and use that as the source to build the wheel.
# This is necessary as the file exclusions mentioned in pyproject.toml are
# otherwise not respected when directly building the wheel.
${SETARCH_CMD} "${PYTHON}" -m build "${WHEEL_PLAT_CONFIG_OPTION[@]}"
GRPCIO_STRIP_TEMPDIR=$(mktemp -d)
GRPCIO_TAR_GZ_LIST=( dist/grpcio-*.tar.gz )
@@ -143,18 +145,14 @@ mv "${GRPCIO_STRIPPED_TAR_GZ}" "${GRPCIO_TAR_GZ}"
# Build gRPC tools package distribution
"${PYTHON}" tools/distrib/python/make_grpcio_tools.py
# Build gRPC tools package source distribution
${SETARCH_CMD} "${PYTHON}" tools/distrib/python/grpcio_tools/setup.py sdist
# Build gRPC tools package binary distribution
# shellcheck disable=SC2086
${SETARCH_CMD} "${PYTHON}" tools/distrib/python/grpcio_tools/setup.py bdist_wheel $WHEEL_PLAT_NAME_FLAG
# Build gRPC tools package source and binary distribution
${SETARCH_CMD} "${PYTHON}" -m build "tools/distrib/python/grpcio_tools" \
"${WHEEL_PLAT_CONFIG_OPTION[@]}"
if [ "$GRPC_BUILD_MAC" == "" ]; then
"${PYTHON}" src/python/grpcio_observability/make_grpcio_observability.py
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_observability/setup.py sdist
# shellcheck disable=SC2086
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_observability/setup.py bdist_wheel $WHEEL_PLAT_NAME_FLAG
${SETARCH_CMD} "${PYTHON}" -m build "src/python/grpcio_observability" \
"${WHEEL_PLAT_CONFIG_OPTION[@]}"
fi
@@ -244,8 +242,7 @@ if [ "$GRPC_BUILD_MAC" == "" ]; then
# Build grpcio_csm_observability distribution
if [ "$GRPC_BUILD_MAC" == "" ]; then
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_csm_observability/setup.py \
sdist bdist_wheel
${SETARCH_CMD} "${PYTHON}" -m build "src/python/grpcio_csm_observability"
cp -r src/python/grpcio_csm_observability/dist/* "$ARTIFACT_DIR"
fi
fi
@@ -256,67 +253,76 @@ fi
# are in a docker image or in a virtualenv.
if [ "$GRPC_BUILD_GRPCIO_TOOLS_DEPENDENTS" != "" ]
then
"${PYTHON}" -m pip install -rrequirements.txt
if [ "$("$PYTHON" -c "import sys; print(sys.version_info[0])")" == "2" ]
then
# shellcheck disable=SC2261
"${PYTHON}" -m pip install futures>=2.2.0 enum34>=1.0.4
fi
"${PYTHON}" -m pip install -r requirements.txt
"${PYTHON}" -m pip install grpcio --no-index --find-links "file://$ARTIFACT_DIR/"
"${PYTHON}" -m pip install grpcio-tools --no-index --find-links "file://$ARTIFACT_DIR/"
# Note(lidiz) setuptools's "sdist" command creates a source tarball, which
# demands an extra step of building the wheel. The building step is merely ran
# through setup.py, but we can optimize it with "bdist_wheel" command, which
# skips the wheel building step.
# Ancillary packages below require source-built grpcio/grpcio_tools packages
# (unavailable on PyPI). `--no-isolation` prevents setuptools from failing to
# find these dependencies in PyPi and use the pre-built packages in the env
# Build xds_protos source distribution
# build.py is invoked as part of generate_projects.
${SETARCH_CMD} "${PYTHON}" tools/distrib/python/xds_protos/setup.py \
sdist bdist_wheel install
# build_xds_protos.py is invoked as part of generate_projects.
${SETARCH_CMD} "${PYTHON}" -m build --no-isolation \
"tools/distrib/python/xds_protos"
cp -r tools/distrib/python/xds_protos/dist/* "$ARTIFACT_DIR"
# Build grpcio_testing source distribution
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_testing/setup.py preprocess \
sdist bdist_wheel
# TODO(ssreenithi): find pyproject.toml/nox equivalent
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_testing/setup.py preprocess
${SETARCH_CMD} "${PYTHON}" -m build src/python/grpcio_testing
cp -r src/python/grpcio_testing/dist/* "$ARTIFACT_DIR"
# Build grpcio_channelz source distribution
# TODO(ssreenithi): find pyproject.toml/nox equivalent
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_channelz/setup.py \
preprocess build_package_protos sdist bdist_wheel
preprocess build_package_protos
${SETARCH_CMD} "${PYTHON}" -m build --no-isolation \
"src/python/grpcio_channelz"
cp -r src/python/grpcio_channelz/dist/* "$ARTIFACT_DIR"
# Build grpcio_health_checking source distribution
# TODO(ssreenithi): find pyproject.toml/nox equivalent
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_health_checking/setup.py \
preprocess build_package_protos sdist bdist_wheel
preprocess build_package_protos
${SETARCH_CMD} "${PYTHON}" -m build --no-isolation \
"src/python/grpcio_health_checking"
cp -r src/python/grpcio_health_checking/dist/* "$ARTIFACT_DIR"
# Build grpcio_reflection source distribution
# TODO(ssreenithi): find pyproject.toml/nox equivalent
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_reflection/setup.py \
preprocess build_package_protos sdist bdist_wheel
preprocess build_package_protos
${SETARCH_CMD} "${PYTHON}" -m build --no-isolation \
"src/python/grpcio_reflection"
cp -r src/python/grpcio_reflection/dist/* "$ARTIFACT_DIR"
# Build grpcio_status source distribution
# TODO(ssreenithi): find pyproject.toml/nox equivalent
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_status/setup.py \
preprocess sdist bdist_wheel
preprocess
${SETARCH_CMD} "${PYTHON}" -m build "src/python/grpcio_status"
cp -r src/python/grpcio_status/dist/* "$ARTIFACT_DIR"
# Install xds-protos as a dependency of grpcio-csds
"${PYTHON}" -m pip install xds-protos --no-index --find-links "file://$ARTIFACT_DIR/"
# Build grpcio_csds source distribution
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_csds/setup.py \
sdist bdist_wheel
${SETARCH_CMD} "${PYTHON}" -m build --no-isolation "src/python/grpcio_csds"
cp -r src/python/grpcio_csds/dist/* "$ARTIFACT_DIR"
# Build grpcio_admin source distribution and it needs the cutting-edge version
# of Channelz and CSDS to be installed.
"${PYTHON}" -m pip install grpcio-channelz --no-index --find-links "file://$ARTIFACT_DIR/"
"${PYTHON}" -m pip install grpcio-csds --no-index --find-links "file://$ARTIFACT_DIR/"
${SETARCH_CMD} "${PYTHON}" src/python/grpcio_admin/setup.py \
sdist bdist_wheel
${SETARCH_CMD} "${PYTHON}" -m build --no-isolation "src/python/grpcio_admin"
cp -r src/python/grpcio_admin/dist/* "$ARTIFACT_DIR"
fi

View File

@@ -106,7 +106,6 @@ echo "query --override_repository=${BAZEL_DEP_NAME}=${BAZEL_DEP_PATH}" >> "tools
PYTHON=${1:-python2.7}
VENV=${2:-$(venv "$PYTHON")}
VENV_RELATIVE_PYTHON=${3:-$(venv_relative_python)}
TOOLCHAIN=${4:-$(toolchain)}
if [ "$(is_msys)" ]; then
echo "MSYS doesn't directly provide the right compiler(s);"
@@ -154,19 +153,19 @@ pip_install --upgrade setuptools==77.0.1
# pip-installs the directory specified. Used because on MSYS the vanilla Windows
# Python gets confused when parsing paths.
pip_install_dir() {
PWD=$(pwd)
local workdir
workdir="$(pwd)"
cd "$1"
($VENV_PYTHON setup.py build_ext -c "$TOOLCHAIN" || true)
$VENV_PYTHON -m pip install --no-deps .
cd "$PWD"
"${VENV_PYTHON}" -m pip install --no-deps --no-build-isolation .
cd "${workdir}"
}
pip_install_dir_and_deps() {
PWD=$(pwd)
local workdir
workdir="$(pwd)"
cd "$1"
($VENV_PYTHON setup.py build_ext -c "$TOOLCHAIN" || true)
$VENV_PYTHON -m pip install .
cd "$PWD"
"${VENV_PYTHON}" -m pip install --no-build-isolation .
cd "${workdir}"
}
pip_install -U gevent
@@ -216,7 +215,7 @@ pip_install_dir "$ROOT/src/python/grpcio_status"
# Build/install status proto mapping
# build.py is invoked as part of generate_projects.sh
# build_xds_protos.py is invoked as part of generate_projects.sh
pip_install_dir "$ROOT/tools/distrib/python/xds_protos"
# Build/install csds
@@ -229,11 +228,11 @@ pip_install_dir "$ROOT/src/python/grpcio_admin"
pip_install_dir "$ROOT/src/python/grpcio_testing"
# Build/install tests
# shellcheck disable=SC2261
pip_install coverage==7.2.0 oauth2client==4.1.0 \
google-auth>=1.35.0 requests==2.31.0 \
pip_install "coverage>=7.9.0" oauth2client==4.1.0 \
"google-auth>=1.35.0" requests==2.31.0 \
rsa==4.0 absl-py==1.4.0 \
opentelemetry-sdk==1.21.0
$VENV_PYTHON "$ROOT/src/python/grpcio_tests/setup.py" preprocess
$VENV_PYTHON "$ROOT/src/python/grpcio_tests/setup.py" build_package_protos
pip_install_dir "$ROOT/src/python/grpcio_tests"

View File

@@ -23,6 +23,7 @@ PYTHON="$(pwd)/${1:-py39/bin/python}"
ROOT=$(pwd)
# TODO(ssreenithi): find pyproject.toml/pytest equivalent
$PYTHON "$ROOT/src/python/grpcio_tests/setup.py" "$2"
mkdir -p "$ROOT/reports"