Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add project metadata generation to Python #2746

Merged
merged 1 commit into from
Aug 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add project metadata generation to Python
  • Loading branch information
soltanmm committed Aug 5, 2015
commit 5c147631d31a8fcaf4447b9c7d48da55e5aaea0d
1 change: 1 addition & 0 deletions src/python/grpcio/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist/
*.egg/
*.eggs/
doc/
_grpcio_metadata.py
26 changes: 26 additions & 0 deletions src/python/grpcio/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import sys

import setuptools
from setuptools.command import build_py

_CONF_PY_ADDENDUM = """
extensions.append('sphinx.ext.napoleon')
Expand Down Expand Up @@ -74,3 +75,28 @@ def run(self):
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)
2 changes: 2 additions & 0 deletions src/python/grpcio/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@

_COMMAND_CLASS = {
'doc': commands.SphinxDocumentation,
'build_project_metadata': commands.BuildProjectMetadata,
'build_py': commands.BuildPy,
}

setuptools.setup(
Expand Down