|
diff -ruN /usr/ports/devel/py-threadpoolctl/Makefile /usr/ports/devel/py-threadpoolctl.patched/Makefile |
|
--- /usr/ports/devel/py-threadpoolctl/Makefile 2024-04-17 19:37:46.592777841 +0200 |
|
+++ /usr/ports/devel/py-threadpoolctl.patched/Makefile 2024-04-17 19:09:48.140323452 +0200 |
|
@@ -20,8 +20,4 @@ |
|
|
|
.include <bsd.port.options.mk> |
|
|
|
-.if ${OPSYS} == FreeBSD && ${OSVERSION} < 1302509 |
|
-IGNORE= does not run on FreeBSD 13.2 or earlier due to handling of dynamically loaded libc |
|
-.endif |
|
- |
|
.include <bsd.port.mk> |
|
diff -ruN /usr/ports/devel/py-threadpoolctl/files/patch-threadpoolctl.py /usr/ports/devel/py-threadpoolctl.patched/files/patch-threadpoolctl.py |
|
--- /usr/ports/devel/py-threadpoolctl/files/patch-threadpoolctl.py 1970-01-01 01:00:00.000000000 +0100 |
|
+++ /usr/ports/devel/py-threadpoolctl.patched/files/patch-threadpoolctl.py 2024-04-17 19:37:34.856053076 +0200 |
|
@@ -0,0 +1,73 @@ |
|
+--- threadpoolctl.py.orig 2024-04-17 15:48:02 UTC |
|
++++ threadpoolctl.py |
|
+@@ -67,6 +67,7 @@ try: |
|
+ except AttributeError: |
|
+ _RTLD_NOLOAD = ctypes.DEFAULT_MODE |
|
+ |
|
++_RTLD_DEFAULT=-2 |
|
+ |
|
+ class LibController(ABC): |
|
+ """Abstract base class for the individual library controllers |
|
+@@ -981,8 +982,62 @@ class ThreadpoolController: |
|
+ self._find_libraries_with_enum_process_module_ex() |
|
+ elif "pyodide" in sys.modules: |
|
+ self._find_libraries_pyodide() |
|
++ elif "freebsd" in sys.platform: |
|
++ self._find_libraries_with_dl_iterate_phdr_freebsd() |
|
+ else: |
|
+ self._find_libraries_with_dl_iterate_phdr() |
|
++ |
|
++ def _find_libraries_with_dl_iterate_phdr_freebsd(self): |
|
++ """Loop through loaded libraries and return binders on supported ones |
|
++ |
|
++ This function is expected to work on POSIX system only. |
|
++ This code is adapted from code by Intel developer @anton-malakhov |
|
++ available at https://github.com/IntelPython/smp |
|
++ |
|
++ Copyright (c) 2017, Intel Corporation published under the BSD 3-Clause |
|
++ license |
|
++ """ |
|
++ |
|
++ parent = ctypes.CDLL(None) |
|
++ |
|
++ dlopen = parent.dlopen |
|
++ dlopen.restype = ctypes.c_void_p |
|
++ |
|
++ dlsym = parent.dlsym |
|
++ dlsym.restype = ctypes.c_void_p |
|
++ |
|
++ dl_iterate_phdr_ptr = dlsym(_RTLD_DEFAULT, b'dl_iterate_phdr') |
|
++ |
|
++ if dl_iterate_phdr_ptr == 0: |
|
++ return [] |
|
++ |
|
++ # Callback function for `dl_iterate_phdr` which is called for every |
|
++ # library loaded in the current process until it returns 1. |
|
++ def match_library_callback(info, size, data): |
|
++ # Get the path of the current library |
|
++ filepath = info.contents.dlpi_name |
|
++ if filepath: |
|
++ filepath = filepath.decode("utf-8") |
|
++ |
|
++ # Store the library controller if it is supported and selected |
|
++ self._make_controller_from_path(filepath) |
|
++ return 0 |
|
++ |
|
++ c_func_signature = ctypes.CFUNCTYPE( |
|
++ ctypes.c_int, # Return type |
|
++ ctypes.POINTER(_dl_phdr_info), |
|
++ ctypes.c_size_t, |
|
++ ctypes.c_char_p, |
|
++ ) |
|
++ c_match_library_callback = c_func_signature(match_library_callback) |
|
++ |
|
++ data = ctypes.c_char_p(b"") |
|
++ |
|
++ dl_iterate_phdr_c_signature = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p) |
|
++ dl_iterate_phdr_c_signature.argtypes = [ c_func_signature, ctypes.c_void_p ] |
|
++ dl_iterate_phdr = dl_iterate_phdr_c_signature(dl_iterate_phdr_ptr) |
|
++ |
|
++ dl_iterate_phdr(c_match_library_callback, data) |
|
+ |
|
+ def _find_libraries_with_dl_iterate_phdr(self): |
|
+ """Loop through loaded libraries and return binders on supported ones |