Skip to content

Commit

Permalink
language and cython diretives back to setup.py, add headers for install
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarzot committed Jan 9, 2025
1 parent 8f7f783 commit d55cf5f
Show file tree
Hide file tree
Showing 25 changed files with 21 additions and 56 deletions.
2 changes: 0 additions & 2 deletions folly/python/__init__.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions folly/python/async_generator.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions folly/python/build_mode.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions folly/python/cast.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions folly/python/coro.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions folly/python/executor.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,7 +47,6 @@ cdef class AsyncioExecutor:
cdef class ProactorExecutor(AsyncioExecutor):
cdef unique_ptr[cProactorExecutor, cProactorExecutorDeleter] cQ


cdef class IocpQueue(dict):
cdef ProactorExecutor _executor

Expand Down
2 changes: 0 additions & 2 deletions folly/python/executor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions folly/python/expected.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
2 changes: 0 additions & 2 deletions folly/python/fbstring.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions folly/python/fiber_manager.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions folly/python/fiber_manager.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 <PyObject*>loop is PyWeakref_GetObject(last_loop):
manager = last_manager

if manager is None:
try:
manager = <FiberManager>(loop_to_controller[loop])
Expand Down
1 change: 0 additions & 1 deletion folly/python/fibers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <Python.h>
#include <folly/Function.h>
#include <folly/synchronization/Hazptr-fwd.h>
#include <folly/fibers/FiberManagerInternal.h>

namespace folly {
Expand Down
2 changes: 0 additions & 2 deletions folly/python/fibers.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions folly/python/function.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
2 changes: 0 additions & 2 deletions folly/python/futures.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions folly/python/iobuf.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions folly/python/iobuf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions folly/python/memory.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 14 additions & 3 deletions folly/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions folly/python/test/iobuf_helper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 3 additions & 5 deletions folly/python/test/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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++',
Expand Down Expand Up @@ -74,7 +74,7 @@
'simplebridgecoro',
sources=[
'simplebridgecoro.pyx',
'../executor_intf.cpp',
# '../executor_intf.cpp',
'../error.cpp',
],
depends=['simplecoro.h'],
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions folly/python/test/simplebridge.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions folly/python/test/simplebridgecoro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions folly/python/test/simplegenerator.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions folly/python/test/test_set_executor_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d55cf5f

Please sign in to comment.