Skip to content

Commit

Permalink
Add Python xDS user agent (grpc#26191)
Browse files Browse the repository at this point in the history
* Add cpp macro to append wrapped language info to xDS user agent

* Add Python xDS user agent

* fix redefinition error and add macro for wrapped lang version

* clang-format

* Revert xds_api.cc changes

* Use two separate macros

* Yapf

* Regenerate projects

* Include _metadata.py in source distributions

* Attempt to fix quote escaping on Windows

Co-authored-by: Mark D. Roth <[email protected]>
  • Loading branch information
gnossen and markdroth authored Jun 14, 2021
1 parent 1e2f19b commit f90716a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions PYTHON-MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ include requirements.txt
include etc/roots.pem
include Makefile
include LICENSE
include _metadata.py
17 changes: 17 additions & 0 deletions _metadata.py
Original file line number Diff line number Diff line change
@@ -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"""
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
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'

Expand Down Expand Up @@ -228,6 +230,9 @@ def check_linker_need_libatomic():
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'
Expand Down
19 changes: 19 additions & 0 deletions templates/_metadata.py.template
Original file line number Diff line number Diff line change
@@ -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()}"""

0 comments on commit f90716a

Please sign in to comment.