@@ -26,11 +26,17 @@ if(thriftpy)
26
26
endif ()
27
27
28
28
if (thriftpy3)
29
+ include (FBPythonWrapper)
30
+ find_package (Python3 COMPONENTS Interpreter Development REQUIRED)
31
+
29
32
set (_cybld "${CMAKE_CURRENT_BINARY_DIR} /cybld" )
30
33
file (MAKE_DIRECTORY "${_cybld} /thrift/python/" )
31
34
file (MAKE_DIRECTORY "${_cybld} /thrift/python/client/" )
32
35
file (MAKE_DIRECTORY "${_cybld} /thrift/python/server/" )
33
36
file (MAKE_DIRECTORY "${_cybld} /thrift/python/server/flagged/" )
37
+ file (MAKE_DIRECTORY "${_cybld} /thrift/python/server_impl/" )
38
+ file (MAKE_DIRECTORY "${_cybld} /thrift/python/server_impl/interceptor/" )
39
+ file (MAKE_DIRECTORY "${_cybld} /thrift/python/streaming/" )
34
40
file (MAKE_DIRECTORY "${_cybld} /thrift/py3/" )
35
41
36
42
# So that cython includes work correctly
@@ -110,6 +116,8 @@ if(thriftpy3)
110
116
${CMAKE_COMMAND} -E create_symlink "${_cybld} /thrift/python/server/server.pyx" "${_cybld} /thrift/python/server.pyx"
111
117
)
112
118
119
+ ########################################################################
120
+ # Symlink files that get mapped directly
113
121
add_custom_target (create_binding_symlink_python ALL )
114
122
file (GLOB BindingFiles
115
123
"python/client/async_client_factory.pxd"
@@ -133,6 +141,10 @@ if(thriftpy3)
133
141
"python/server/server.pxd"
134
142
"python/std_libcpp.pxd"
135
143
"python/stream.pxd"
144
+ "python/streaming/py_promise.pxd"
145
+ "python/streaming/python_user_exception.pxd"
146
+ "python/streaming/sink.pxd"
147
+ "python/streaming/stream.pxd"
136
148
"python/types.pxd"
137
149
"python/util.pxd"
138
150
@@ -156,8 +168,13 @@ if(thriftpy3)
156
168
"python/mutable_types.pyx"
157
169
"python/protocol.pyx"
158
170
"python/serializer.pyx"
171
+ "python/server/request_context.pyx"
159
172
"python/server/server.pyx"
160
173
"python/stream.pyx"
174
+ "python/streaming/py_promise.pyx"
175
+ "python/streaming/python_user_exception.pyx"
176
+ "python/streaming/sink.pyx"
177
+ "python/streaming/stream.pyx"
161
178
"python/util.pyx"
162
179
163
180
"python/abstract_types.py"
@@ -169,14 +186,15 @@ if(thriftpy3)
169
186
"python/Serializer.h"
170
187
"python/types.h"
171
188
172
- "python/server/flagged/EnableResourcePoolsForPython.cpp"
173
189
"python/server/PythonAsyncProcessor.cpp"
174
190
"python/server/PythonAsyncProcessorFactory.cpp"
191
+ "python/streaming/PythonUserException.cpp"
192
+ "python/streaming/Sink.cpp"
193
+ "python/streaming/StreamElementEncoder.cpp"
175
194
)
176
195
177
196
foreach (_src ${BindingFiles} )
178
197
file (RELATIVE_PATH _filerelpath ${CMAKE_CURRENT_SOURCE_DIR} ${_src} )
179
- get_filename_component (_target_file "${_src} " NAME )
180
198
181
199
message (
182
200
STATUS
@@ -192,6 +210,40 @@ if(thriftpy3)
192
210
)
193
211
endforeach ()
194
212
213
+
214
+ ########################################################################
215
+ # Symlink files that get mapped server -> server_impl
216
+ file (GLOB BindingFiles
217
+ "python/server/async_processor.pxd"
218
+ "python/server/event_handler.pxd"
219
+ "python/server/interceptor/server_module.pxd"
220
+ "python/server/python_async_processor.pxd"
221
+ "python/server/request_context.pxd"
222
+
223
+ "python/server/python_async_processor.pyx"
224
+
225
+ "python/server/PythonAsyncProcessor.cpp"
226
+ "python/server/PythonAsyncProcessorFactory.cpp"
227
+ )
228
+ foreach (_src ${BindingFiles} )
229
+ file (RELATIVE_PATH _filerelpath ${CMAKE_CURRENT_SOURCE_DIR} /python/server ${_src} )
230
+
231
+ message (
232
+ STATUS
233
+ "Linking ${_src} to ${_cybld} /thrift/python/server_impl/${_filerelpath} "
234
+ )
235
+
236
+ add_custom_command (
237
+ TARGET
238
+ create_binding_symlink_python
239
+ PRE_BUILD
240
+ COMMAND
241
+ ${CMAKE_COMMAND} -E create_symlink "${_src} " "${_cybld} /thrift/python/server_impl/${_filerelpath} "
242
+ )
243
+ endforeach ()
244
+
245
+ ########################################################################
246
+ # Symlink all the py3 files
195
247
add_custom_target (create_binding_symlink_py3 ALL )
196
248
file (GLOB BindingFiles
197
249
"${CMAKE_CURRENT_SOURCE_DIR} /py3/*.pxd"
@@ -227,16 +279,28 @@ if(thriftpy3)
227
279
thriftcpp2
228
280
WORKING_DIRECTORY ${_cybld}
229
281
)
282
+
283
+ set (_folly_site_packages "${CMAKE_INSTALL_PREFIX} /../folly/lib/python${Python3_VERSION_MAJOR} .${Python3_VERSION_MINOR} /site-packages" )
284
+ # FIXME: For some reason, FOLLY_VERSION is not defined
285
+ set (_folly_version "0.0.1" )
286
+ set (_folly_PYTHONPATH "${_folly_site_packages} /folly-${_folly_version} -py${Python3_VERSION_MAJOR} .${Python3_VERSION_MINOR} -linux-x86_64.egg" )
287
+
230
288
add_custom_command (TARGET thrift_python_types_bindings
231
289
COMMAND ${CMAKE_COMMAND} -E env
232
- "CFLAGS=${CMAKE_C_FLAGS} "
233
- "CXXFLAGS=${CMAKE_CXX_FLAGS} "
290
+ "CFLAGS=${CMAKE_C_FLAGS} ${FBTHRIFT_CXX_OPTIONS} "
291
+ "CXXFLAGS=${CMAKE_CXX_FLAGS} ${FBTHRIFT_CXX_OPTIONS} "
234
292
"CXX=${CMAKE_CXX_COMPILER} "
235
- python3 ${CMAKE_CURRENT_SOURCE_DIR} /setup.py -v --api-only
293
+ "PYTHONPATH=${_cybld} /lib:${_cybld} :${_folly_PYTHONPATH} :$ENV{PYTHONPATH} "
294
+ ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} /setup.py -v --api-only
236
295
BYPRODUCTS
237
- ${_cybld} /thrift/python/types_api .h
296
+ ${_cybld} /thrift/python/_types_api .h
238
297
${_cybld} /thrift/python/server/server_api.h
239
- ${_cybld} /thrift/python/util_api.h
298
+ ${_cybld} /thrift/python/server_impl/python_async_processor_api.h
299
+ ${_cybld} /thrift/python/streaming/sink_api.h
300
+ ${_cybld} /thrift/python/_stream_api.h
301
+ DEPENDS
302
+ ${CMAKE_CURRENT_SOURCE_DIR} /setup.py
303
+ # FIXME: add .pxd/.pyx files here
240
304
WORKING_DIRECTORY ${_cybld}
241
305
)
242
306
@@ -247,6 +311,7 @@ if(thriftpy3)
247
311
WORKING_DIRECTORY ${_cybld} )
248
312
file (MAKE_DIRECTORY "${_cybld} /thrift/lib/python/" )
249
313
file (MAKE_DIRECTORY "${_cybld} /thrift/lib/python/server" )
314
+ file (MAKE_DIRECTORY "${_cybld} /thrift/lib/python/streaming" )
250
315
file (MAKE_DIRECTORY "${_cybld} /thrift/lib/py3/" )
251
316
252
317
add_custom_command (
@@ -271,13 +336,13 @@ if(thriftpy3)
271
336
TARGET
272
337
create_cython_types_api_symlink
273
338
COMMAND
274
- ${CMAKE_COMMAND} -E create_symlink "${_cybld} /thrift/python/_util_api .h" "${_cybld} /thrift/lib/python/util_api .h"
339
+ ${CMAKE_COMMAND} -E create_symlink "${_cybld} /thrift/python/server_impl/python_async_processor_api .h" "${_cybld} /thrift/lib/python/server/python_async_processor_api .h"
275
340
)
276
341
add_custom_command (
277
342
TARGET
278
343
create_cython_types_api_symlink
279
344
COMMAND
280
- ${CMAKE_COMMAND} -E create_symlink "${_cybld} /thrift/python/_util .h" "${_cybld} /thrift/lib/python/_util .h"
345
+ ${CMAKE_COMMAND} -E create_symlink "${_cybld} /thrift/python/streaming/sink_api .h" "${_cybld} /thrift/lib/python/streaming/sink_api .h"
281
346
)
282
347
add_custom_command (
283
348
TARGET
@@ -296,8 +361,9 @@ if(thriftpy3)
296
361
python/client/OmniClient.cpp
297
362
python/client/RequestChannel.cpp
298
363
python/client/ssl.cpp
364
+ python/streaming/PythonUserException.cpp
365
+ python/streaming/StreamElementEncoder.cpp
299
366
python/types.cpp
300
- python/util.cpp
301
367
python/Serializer.cpp
302
368
py3/stream.cpp
303
369
)
@@ -306,22 +372,34 @@ if(thriftpy3)
306
372
target_compile_definitions (thrift_python_cpp PRIVATE BOOST_NO_AUTO_PTR)
307
373
target_compile_definitions (thrift_python_cpp PRIVATE THRIFT_NO_HTTP_CLIENT_CHANNEL)
308
374
target_include_directories (thrift_python_cpp PRIVATE "${_cybld} " )
375
+ target_include_directories (thrift_python_cpp PRIVATE "${CMAKE_CURRENT_SOURCE_DIR} " )
376
+ target_include_directories (thrift_python_cpp PRIVATE Folly::folly_python_cpp)
309
377
target_link_libraries (
310
378
thrift_python_cpp
311
379
PUBLIC
312
380
thriftcpp2
313
381
Folly::folly
314
382
Folly::folly_python_cpp
383
+ PRIVATE
384
+ Python3::Python
315
385
)
316
386
install (
317
387
TARGETS thrift_python_cpp
318
- EXPORT thrift
388
+ EXPORT fbthrift-exports
389
+ # FIXME: Consider DESTINATION ${LIB_INSTALL_DIR}
319
390
)
320
391
install (
321
392
TARGETS thrift_python_cpp
322
393
DESTINATION ${py_install_dir}
323
394
)
324
395
396
+ wrap_non_fb_python_library(thrift_python_cpp thrift)
397
+ install (
398
+ TARGETS thrift_python_cpp.py_lib
399
+ EXPORT fbthrift-exports
400
+ DESTINATION ${LIB_INSTALL_DIR}
401
+ )
402
+
325
403
#####
326
404
# Now build everything else in lib/python, including all remaining Cython
327
405
# modules that depend on types_api.h and thrift_python_cpp.
@@ -332,8 +410,10 @@ if(thriftpy3)
332
410
generate_apache_thrift_metadata_python
333
411
create_binding_symlink_python
334
412
create_binding_symlink_py3
413
+ Folly::folly_python_cpp
335
414
thriftcpp2
336
415
thrift_python_cpp
416
+ thrift_python_types_bindings
337
417
WORKING_DIRECTORY ${_cybld}
338
418
)
339
419
@@ -357,29 +437,38 @@ if(thriftpy3)
357
437
358
438
add_custom_command (TARGET thrift_python_and_py3_bindings
359
439
COMMAND ${CMAKE_COMMAND} -E env
360
- "CFLAGS=${CMAKE_C_FLAGS} "
361
- "CXXFLAGS=${CMAKE_CXX_FLAGS} "
440
+ "CFLAGS=${CMAKE_C_FLAGS} ${FBTHRIFT_CXX_OPTIONS} "
441
+ "CXXFLAGS=${CMAKE_CXX_FLAGS} ${FBTHRIFT_CXX_OPTIONS} "
362
442
"CXX=${CMAKE_CXX_COMPILER} "
443
+ "PYTHONPATH=${_cybld} /lib:${_cybld} :${_folly_PYTHONPATH} :$ENV{PYTHONPATH} "
363
444
python3 ${CMAKE_CURRENT_SOURCE_DIR} /setup.py -v
364
445
build_ext -f ${incs} ${libs} --libpython ${python_libname}
446
+ DEPENDS
447
+ ${CMAKE_CURRENT_SOURCE_DIR} /setup.py
365
448
WORKING_DIRECTORY ${_cybld}
366
449
)
367
450
add_custom_command (TARGET thrift_python_and_py3_bindings
368
451
COMMAND ${CMAKE_COMMAND} -E env
369
- "CFLAGS=${CMAKE_C_FLAGS} "
370
- "CXXFLAGS=${CMAKE_CXX_FLAGS} "
452
+ "CFLAGS=${CMAKE_C_FLAGS} ${FBTHRIFT_CXX_OPTIONS} "
453
+ "CXXFLAGS=${CMAKE_CXX_FLAGS} ${FBTHRIFT_CXX_OPTIONS} "
371
454
"CXX=${CMAKE_CXX_COMPILER} "
455
+ "PYTHONPATH=${_cybld} /lib:${_cybld} :${_folly_PYTHONPATH} :$ENV{PYTHONPATH} "
372
456
python3 ${CMAKE_CURRENT_SOURCE_DIR} /setup.py -v
373
457
bdist_wheel --libpython ${python_libname}
458
+ DEPENDS
459
+ ${CMAKE_CURRENT_SOURCE_DIR} /setup.py
374
460
WORKING_DIRECTORY ${_cybld}
375
461
)
376
462
add_custom_command (TARGET thrift_python_and_py3_bindings POST_BUILD
377
463
COMMAND ${CMAKE_COMMAND} -E env
378
- "CFLAGS=${CMAKE_C_FLAGS} "
379
- "CXXFLAGS=${CMAKE_CXX_FLAGS} "
464
+ "CFLAGS=${CMAKE_C_FLAGS} ${FBTHRIFT_CXX_OPTIONS} "
465
+ "CXXFLAGS=${CMAKE_CXX_FLAGS} ${FBTHRIFT_CXX_OPTIONS} "
380
466
"CXX=${CMAKE_CXX_COMPILER} "
467
+ "PYTHONPATH=${_cybld} /lib:${_cybld} :${_folly_PYTHONPATH} :$ENV{PYTHONPATH} "
381
468
python3 ${CMAKE_CURRENT_SOURCE_DIR} /setup.py -v
382
469
install --prefix ${CMAKE_INSTALL_PREFIX} --libpython ${python_libname}
470
+ DEPENDS
471
+ ${CMAKE_CURRENT_SOURCE_DIR} /setup.py
383
472
WORKING_DIRECTORY ${_cybld}
384
473
)
385
474
@@ -390,8 +479,8 @@ if(thriftpy3)
390
479
install (CODE "
391
480
execute_process(
392
481
COMMAND ${CMAKE_COMMAND} -E env
393
- \" CFLAGS=${CMAKE_C_FLAGS} \"
394
- \" CXXFLAGS=${CMAKE_CXX_FLAGS} \"
482
+ \" CFLAGS=${CMAKE_C_FLAGS} ${FBTHRIFT_CXX_OPTIONS} \"
483
+ \" CXXFLAGS=${CMAKE_CXX_FLAGS} ${FBTHRIFT_CXX_OPTIONS} \"
395
484
python3 ${CMAKE_CURRENT_SOURCE_DIR} /setup.py install -v
396
485
--prefix ${py_install_dir} --libpython ${python_libname}
397
486
COMMAND_ECHO STDOUT
0 commit comments