Search code examples
thrift

Thrift generate python dependencies


I have 2 thrift definition files within the same namespace

file1.thrift

namespace some_name
some types

file2.thrift

namespace some_name
include "file1.thrift"
some types ....

when doing

thrift --gen py -r -out folder file2.thrift

I expect to get the types defined in file1.thrift generated in the python code. But that is not the case... What am I missing here?

Thanks


Solution

  • Cause

    The Apache Thrift compiler overwrites existing files without a warning. Because you use the same namespace, certain files like ttypes.py and constants.py are overwritten when the next IDL file is processed.

    Solution

    • Always put declarations belonging to one namespace into one Thrift IDL file
    • Use different namespaces for different Thrift IDL files