Skip to content

Commit

Permalink
Install apache.thrift.metadata in OSS thrift-python build
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jmswen authored and facebook-github-bot committed Feb 12, 2025
1 parent dadb9cd commit 94a6664
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
27 changes: 26 additions & 1 deletion third-party/thrift/src/thrift/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions third-party/thrift/src/thrift/lib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
"thrift.python",
"thrift.python.client",
"thrift.py3",
"apache.thrift.metadata",
],
package_data={"": ["*.pxd", "*.h"]},
setup_requires=["cython"],
Expand Down

0 comments on commit 94a6664

Please sign in to comment.