diff --git a/folly/python/__init__.pxd b/folly/python/__init__.pxd index af229dd61e7..2dcd97f3721 100644 --- a/folly/python/__init__.pxd +++ b/folly/python/__init__.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from libcpp cimport bool as cbool diff --git a/folly/python/async_generator.pxd b/folly/python/async_generator.pxd index c7bb270b6ef..c7a2666fdc6 100644 --- a/folly/python/async_generator.pxd +++ b/folly/python/async_generator.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from folly.coro cimport cFollyCoroTask diff --git a/folly/python/build_mode.pyx b/folly/python/build_mode.pyx index 600c21b2e90..4f66f3f06a9 100644 --- a/folly/python/build_mode.pyx +++ b/folly/python/build_mode.pyx @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from folly cimport cFollyIsDebug, cFollyIsTsan diff --git a/folly/python/cast.pxd b/folly/python/cast.pxd index ab281e75cc6..fc0a23236c6 100644 --- a/folly/python/cast.pxd +++ b/folly/python/cast.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 cdef extern from "folly/lang/Cast.h" namespace "folly" nogil: cdef T down_cast_ref "folly::down_cast"[T, S](S ref) diff --git a/folly/python/coro.pxd b/folly/python/coro.pxd index c9afc1d1871..4b2490afaff 100644 --- a/folly/python/coro.pxd +++ b/folly/python/coro.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from cpython.ref cimport PyObject from folly cimport cFollyExecutor, cFollyTry diff --git a/folly/python/executor.pxd b/folly/python/executor.pxd index 2b150bd355c..09116900c27 100644 --- a/folly/python/executor.pxd +++ b/folly/python/executor.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from libcpp.memory cimport unique_ptr from folly cimport cFollyExecutor @@ -49,7 +47,6 @@ cdef class AsyncioExecutor: cdef class ProactorExecutor(AsyncioExecutor): cdef unique_ptr[cProactorExecutor, cProactorExecutorDeleter] cQ - cdef class IocpQueue(dict): cdef ProactorExecutor _executor diff --git a/folly/python/executor.pyx b/folly/python/executor.pyx index e9d43f59390..9c13d408b53 100644 --- a/folly/python/executor.pyx +++ b/folly/python/executor.pyx @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 import asyncio import sys diff --git a/folly/python/expected.pxd b/folly/python/expected.pxd index 579358244d0..d4453fa02bc 100644 --- a/folly/python/expected.pxd +++ b/folly/python/expected.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 cdef extern from "folly/Expected.h" namespace "folly" nogil: cdef cppclass cExpected "folly::Expected"[T, E]: diff --git a/folly/python/fbstring.pxd b/folly/python/fbstring.pxd index 6e663e26863..a9497ec4de1 100644 --- a/folly/python/fbstring.pxd +++ b/folly/python/fbstring.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from libcpp.string cimport string diff --git a/folly/python/fiber_manager.pxd b/folly/python/fiber_manager.pxd index 63b47d5804f..bceb9d472c9 100644 --- a/folly/python/fiber_manager.pxd +++ b/folly/python/fiber_manager.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from libcpp.memory cimport unique_ptr from libcpp cimport bool diff --git a/folly/python/fiber_manager.pyx b/folly/python/fiber_manager.pyx index b5eac4a6154..c7faf10d313 100644 --- a/folly/python/fiber_manager.pyx +++ b/folly/python/fiber_manager.pyx @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 import asyncio +from cpython cimport PyObject from cython.operator cimport dereference as deref from cpython.weakref cimport PyWeakref_NewRef, PyWeakref_GetObject -from cpython cimport PyObject + from libcpp.memory cimport unique_ptr from folly.executor cimport get_executor from libcpp.cast cimport ( @@ -76,9 +75,10 @@ cdef cFiberManager* get_fiber_manager(const cFiberManagerOptions& opts): loop = asyncio.get_event_loop() cdef FiberManager manager = None - + # deprecated: PyWeakref_GetObject - migrate to PyWeakref_GetRef if last_loop is not None and loop is PyWeakref_GetObject(last_loop): manager = last_manager + if manager is None: try: manager = (loop_to_controller[loop]) diff --git a/folly/python/fibers.h b/folly/python/fibers.h index a3a5178e0ef..0f3da99f381 100644 --- a/folly/python/fibers.h +++ b/folly/python/fibers.h @@ -23,7 +23,6 @@ #include #include -#include #include namespace folly { diff --git a/folly/python/fibers.pxd b/folly/python/fibers.pxd index 29ed69dadc5..a6c18345ade 100644 --- a/folly/python/fibers.pxd +++ b/folly/python/fibers.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from cpython.ref cimport PyObject from folly cimport cFollyTry diff --git a/folly/python/function.pxd b/folly/python/function.pxd index e4b37ef97bf..6ec2dd87f7f 100644 --- a/folly/python/function.pxd +++ b/folly/python/function.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 cdef extern from "folly/Function.h" namespace "folly" nogil: cdef cppclass cFunction "folly::Function"[T]: diff --git a/folly/python/futures.pxd b/folly/python/futures.pxd index 14e84313d0e..9187f55bf92 100644 --- a/folly/python/futures.pxd +++ b/folly/python/futures.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from cpython.ref cimport PyObject from folly cimport cFollyTry, cFollyFuture, cFollyExecutor, cFollySemiFuture diff --git a/folly/python/iobuf.pxd b/folly/python/iobuf.pxd index 21211faca64..718bfa3e557 100644 --- a/folly/python/iobuf.pxd +++ b/folly/python/iobuf.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language = c++ -# cython: language_level=3, c_string_encoding=utf8 from libcpp.string cimport string from libc.stdint cimport uint64_t diff --git a/folly/python/iobuf.pyx b/folly/python/iobuf.pyx index 3612d940a07..7c575c5c168 100644 --- a/folly/python/iobuf.pyx +++ b/folly/python/iobuf.pyx @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 import sys from builtins import memoryview as py_memoryview diff --git a/folly/python/memory.pxd b/folly/python/memory.pxd index cfe943624db..328b9c5dbd5 100644 --- a/folly/python/memory.pxd +++ b/folly/python/memory.pxd @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 from libcpp.memory cimport shared_ptr, unique_ptr diff --git a/folly/python/setup.py b/folly/python/setup.py index 4debcd01452..d084b6d1640 100755 --- a/folly/python/setup.py +++ b/folly/python/setup.py @@ -67,8 +67,9 @@ # Add (prepend) library paths from LD_LIBRARY_PATHs if ldpath := os.environ.get('LD_LIBRARY_PATH'): - library_dirs[:0] = ldpath.split(':') - if folly_lib and folly_lib not in ldpath.split(':'): + ldpaths = ldpath.split(':') + library_dirs[:0] = ldpaths + if folly_lib and folly_lib not in ldpaths: print(f'export LD_LIBRARY_PATH="{folly_lib}:{ldpath}"\n') else: print(f'export LD_LIBRARY_PATH="{ldpath}"\n') @@ -82,6 +83,10 @@ 'folly/ProactorExecutor.cpp', 'folly/error.cpp', ], + headers=[ + 'folly/python/AsyncioExecutor.h', + 'folly/python/ProactorExecutor.h', + ], language='c++', extra_compile_args=compile_args, include_dirs=include_dirs, @@ -96,6 +101,11 @@ 'folly/iobuf_ext.cpp', 'folly/error.cpp', ], + headers=[ + 'folly/python/iobuf_intf.h', + 'folly/python/iobuf_ext.h', + ], + language='c++', extra_compile_args=compile_args, include_dirs=include_dirs, @@ -118,6 +128,7 @@ Extension( 'folly.build_mode', sources=['folly/build_mode.pyx'], + language='c++', extra_compile_args=compile_args, include_dirs=include_dirs, library_dirs=library_dirs, @@ -135,7 +146,7 @@ packages=['folly'], setup_requires=['cython'], zip_safe=False, - package_data={'': ['*.pxd', '*.pyi', '*.h', '__init__.py']}, + package_data={'': ['*.pxd', '*.pyi', '__init__.py', '*_api.h']}, ext_modules=cythonize( exts, verbose=True, diff --git a/folly/python/test/iobuf_helper.pyx b/folly/python/test/iobuf_helper.pyx index 24ba01ed88b..65f2fca7bfd 100644 --- a/folly/python/test/iobuf_helper.pyx +++ b/folly/python/test/iobuf_helper.pyx @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, cpp_locals=True, c_string_encoding=utf8 from folly.iobuf cimport from_unique_ptr, createChain, IOBuf, WritableIOBuf, writable_from_unique_ptr diff --git a/folly/python/test/setup.py b/folly/python/test/setup.py index 9f1c9f0ba2f..53bf4366de6 100644 --- a/folly/python/test/setup.py +++ b/folly/python/test/setup.py @@ -41,9 +41,9 @@ 'simplebridge', sources=[ 'simplebridge.pyx', - '../executor_intf.cpp', + # '../executor_intf.cpp', '../error.cpp', - '../fibers.cpp' + # '../fibers.cpp' ], depends=['simple.h'], language='c++', @@ -74,7 +74,7 @@ 'simplebridgecoro', sources=[ 'simplebridgecoro.pyx', - '../executor_intf.cpp', + # '../executor_intf.cpp', '../error.cpp', ], depends=['simplecoro.h'], @@ -111,8 +111,6 @@ setup( name='folly_test', setup_requires=['cython'], - zip_safe=False, - package_data={'': ['*.pxd', '*.pyi', '*.h']}, ext_modules=cythonize( exts, verbose=True, diff --git a/folly/python/test/simplebridge.pyx b/folly/python/test/simplebridge.pyx index 5de762f7920..3e8d3464a33 100644 --- a/folly/python/test/simplebridge.pyx +++ b/folly/python/test/simplebridge.pyx @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 import asyncio from folly.futures cimport bridgeFuture, bridgeSemiFuture diff --git a/folly/python/test/simplebridgecoro.pyx b/folly/python/test/simplebridgecoro.pyx index 7efd500932f..7cd6f5ca99e 100644 --- a/folly/python/test/simplebridgecoro.pyx +++ b/folly/python/test/simplebridgecoro.pyx @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 import asyncio from folly.coro cimport cFollyCoroTask, bridgeCoroTask, bridgeCoroTaskWithCancellation, cFollyCancellationSource diff --git a/folly/python/test/simplegenerator.pyx b/folly/python/test/simplegenerator.pyx index 96033598312..ff76ee0b5a3 100644 --- a/folly/python/test/simplegenerator.pyx +++ b/folly/python/test/simplegenerator.pyx @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 import asyncio from cpython.ref cimport PyObject diff --git a/folly/python/test/test_set_executor_cython.pyx b/folly/python/test/test_set_executor_cython.pyx index 9048df361fc..96d4465cded 100644 --- a/folly/python/test/test_set_executor_cython.pyx +++ b/folly/python/test/test_set_executor_cython.pyx @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# distutils: language=c++ -# cython: language_level=3, c_string_encoding=utf8 import asyncio