diff --git a/PYTHON-MANIFEST.in b/PYTHON-MANIFEST.in index 890a2faacb5..355f5bf1533 100644 --- a/PYTHON-MANIFEST.in +++ b/PYTHON-MANIFEST.in @@ -24,3 +24,4 @@ include requirements.txt include etc/roots.pem include Makefile include LICENSE +include _metadata.py diff --git a/_metadata.py b/_metadata.py new file mode 100644 index 00000000000..28c861c8677 --- /dev/null +++ b/_metadata.py @@ -0,0 +1,17 @@ +# Copyright 2021 The 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/_metadata.py.template`!!! + +__version__ = """1.39.0.dev0""" diff --git a/setup.py b/setup.py index 32b14e3bb39..b85a04467a8 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,8 @@ from setuptools.command import egg_info import subprocess from subprocess import PIPE +import _metadata + # Redirect the manifest template from MANIFEST.in to PYTHON-MANIFEST.in. egg_info.manifest_maker.template = 'PYTHON-MANIFEST.in' @@ -228,6 +230,9 @@ EXTRA_ENV_COMPILE_ARGS = os.environ.get('GRPC_PYTHON_CFLAGS', None) EXTRA_ENV_LINK_ARGS = os.environ.get('GRPC_PYTHON_LDFLAGS', None) if EXTRA_ENV_COMPILE_ARGS is None: EXTRA_ENV_COMPILE_ARGS = ' -std=c++11' + EXTRA_ENV_COMPILE_ARGS += ' \'-DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"\\\"Python\\\"\"\'' + EXTRA_ENV_COMPILE_ARGS += ' \'-DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"\\\"{}\\\"\"\''.format( + _metadata.__version__) if 'win32' in sys.platform: if sys.version_info < (3, 5): EXTRA_ENV_COMPILE_ARGS += ' -D_hypot=hypot' diff --git a/templates/_metadata.py.template b/templates/_metadata.py.template new file mode 100644 index 00000000000..a0eafce8a1c --- /dev/null +++ b/templates/_metadata.py.template @@ -0,0 +1,19 @@ +%YAML 1.2 +--- | + # Copyright 2021 The 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/_metadata.py.template`!!! + + __version__ = """${settings.python_version.pep440()}"""