#Thriftipy Tool for auto-generation and packaging thrift idls for Python
Installation
$ pip install Thriftipy==0.0.1-dev
Usage
- Put this code snippet in setup.py where thrift-idls are in folder 'idls' and we wish to create package 'sample' to include the generated source.
from setuptools import setup, find_packages, Command
from thriftipy import ThriftGenerator
class generate_thrift(Command):
description = ""
user_options = []
def initialize_options(self):
self.idl_dir = 'idls'
self.gen_dir = 'sample'
self.gen = ThriftGenerator(self.idl_dir, self.gen_dir)
def run(self):
self.gen.generate()
setup(
name='sample',
....
include_package_data=True,
package_data={'sample':['*.thrift']},
cmdclass={'thrift': generate_thrift},
)
- Create a file MANIFEST.in and put this line in it. This will include all thrift idls in sample package.
include sample/*.thrift
-
Run
$ python setup.py thrift
to generate python code from idls. -
Run standard packaging commands to package, install or upload it.