From 94a66643d50062855535d2d4089aead27c325d39 Mon Sep 17 00:00:00 2001 From: Jon Maltiel Swenson Date: Tue, 11 Feb 2025 18:21:42 -0800 Subject: [PATCH] Install apache.thrift.metadata in OSS thrift-python build Summary: This diff is a companion to the last diff, but factored out for slightly easier review. This diff adds OSS build support for the `apache.thrift.metadata` module, which is required for any `thrift.python.server.ThriftServer` to run correctly. Reviewed By: xli Differential Revision: D69277920 fbshipit-source-id: 441ed71817f3358a54fdd6bc355dc65bd6415eb1 --- .../thrift/src/thrift/lib/CMakeLists.txt | 27 ++++++++++++++++++- third-party/thrift/src/thrift/lib/setup.py | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/third-party/thrift/src/thrift/lib/CMakeLists.txt b/third-party/thrift/src/thrift/lib/CMakeLists.txt index 224b65ba79a38b..f318c28dc3e2a5 100644 --- a/third-party/thrift/src/thrift/lib/CMakeLists.txt +++ b/third-party/thrift/src/thrift/lib/CMakeLists.txt @@ -38,8 +38,32 @@ if(thriftpy3) file(TOUCH "${_cybld}/thrift/python/__init__.pxd") file(TOUCH "${_cybld}/thrift/py3/__init__.pxd") + ### + # First, run Thrift compiler on metadata.thrift. thrift-python runtime depends on + # apache.thrift.metadata package, which is created and installed later in setup.py. + ### + add_custom_target( + generate_apache_thrift_metadata_python + COMMAND + thrift1 -I ${CMAKE_SOURCE_DIR} --out . --gen mstch_python + ${CMAKE_CURRENT_SOURCE_DIR}/thrift/metadata.thrift + WORKING_DIRECTORY ${_cybld} + BYPRODUCTS + ${_cybld}/apache/thrift/metadata/thrift_abstract_types.py + ${_cybld}/apache/thrift/metadata/thrift_clients.py + ${_cybld}/apache/thrift/metadata/thrift_enums.py + ${_cybld}/apache/thrift/metadata/thrift_metadata.py + ${_cybld}/apache/thrift/metadata/thrift_mutable_clients.py + ${_cybld}/apache/thrift/metadata/thrift_mutable_services.py + ${_cybld}/apache/thrift/metadata/thrift_mutable_types.py + ${_cybld}/apache/thrift/metadata/thrift_mutable_types.pyi + ${_cybld}/apache/thrift/metadata/thrift_services.py + ${_cybld}/apache/thrift/metadata/thrift_types.py + ${_cybld}/apache/thrift/metadata/thrift_types.pyi + ) + #### - # First, prepare for building cython extensions by creating the necessary symlinks in the cybld directory + # Next, prepare for building cython extensions by creating the necessary symlinks in the cybld directory #### add_custom_target(create_binding_symlink_python_types ALL) foreach( @@ -300,6 +324,7 @@ if(thriftpy3) add_custom_target( thrift_python_and_py3_bindings ALL DEPENDS + generate_apache_thrift_metadata_python create_binding_symlink_python create_binding_symlink_py3 thriftcpp2 diff --git a/third-party/thrift/src/thrift/lib/setup.py b/third-party/thrift/src/thrift/lib/setup.py index e87d313f84e75b..3f2e5beea36885 100644 --- a/third-party/thrift/src/thrift/lib/setup.py +++ b/third-party/thrift/src/thrift/lib/setup.py @@ -254,6 +254,7 @@ "thrift.python", "thrift.python.client", "thrift.py3", + "apache.thrift.metadata", ], package_data={"": ["*.pxd", "*.h"]}, setup_requires=["cython"],