diff options
author | Nathaniel Manista <nathaniel@google.com> | 2015-08-05 17:48:46 -0700 |
---|---|---|
committer | Nathaniel Manista <nathaniel@google.com> | 2015-08-05 17:48:46 -0700 |
commit | 7098b1ba645074c47675a731243aa929c67bb46f (patch) | |
tree | 59f3dbb1d4525b850bf7e8c6f38d6f2466268588 /src/python/grpcio | |
parent | 5148694b2249e21468191657f004c47e2e69ed22 (diff) | |
parent | 5c147631d31a8fcaf4447b9c7d48da55e5aaea0d (diff) |
Merge pull request #2746 from soltanmm/user-agent
Add project metadata generation to Python.
Diffstat (limited to 'src/python/grpcio')
-rw-r--r-- | src/python/grpcio/.gitignore | 1 | ||||
-rw-r--r-- | src/python/grpcio/commands.py | 26 | ||||
-rw-r--r-- | src/python/grpcio/setup.py | 2 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/python/grpcio/.gitignore b/src/python/grpcio/.gitignore index efbe1737ba..4c02b8d14d 100644 --- a/src/python/grpcio/.gitignore +++ b/src/python/grpcio/.gitignore @@ -6,3 +6,4 @@ dist/ *.egg/ *.eggs/ doc/ +_grpcio_metadata.py diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py index 605d9d5612..89c0fbf0f3 100644 --- a/src/python/grpcio/commands.py +++ b/src/python/grpcio/commands.py @@ -34,6 +34,7 @@ import os.path import sys import setuptools +from setuptools.command import build_py _CONF_PY_ADDENDUM = """ extensions.append('sphinx.ext.napoleon') @@ -74,3 +75,28 @@ class SphinxDocumentation(setuptools.Command): conf_file.write(_CONF_PY_ADDENDUM) sphinx.main(['', os.path.join('doc', 'src'), os.path.join('doc', 'build')]) + +class BuildProjectMetadata(setuptools.Command): + """Command to generate project metadata in a module.""" + + description = '' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + with open('grpc/_grpcio_metadata.py', 'w') as module_file: + module_file.write('__version__ = """{}"""'.format( + self.distribution.get_version())) + + +class BuildPy(build_py.build_py): + """Custom project build command.""" + + def run(self): + self.run_command('build_project_metadata') + build_py.build_py.run(self) diff --git a/src/python/grpcio/setup.py b/src/python/grpcio/setup.py index e408f2ace9..caa71a4f7c 100644 --- a/src/python/grpcio/setup.py +++ b/src/python/grpcio/setup.py @@ -98,6 +98,8 @@ _SETUP_REQUIRES = ( _COMMAND_CLASS = { 'doc': commands.SphinxDocumentation, + 'build_project_metadata': commands.BuildProjectMetadata, + 'build_py': commands.BuildPy, } setuptools.setup( |