[3.13] gh-122907: Fix Builds Without HAVE_DYNAMIC_LOADING Set (gh-122952) by miss-islington · Pull Request #122984 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Include/internal/pycore_importdl.h
16 changes: 8 additions & 8 deletions Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,14 +1797,14 @@ def _get_supported_file_loaders():

Each item is a tuple (loader, suffixes).
"""
if sys.platform in {"ios", "tvos", "watchos"}:
extension_loaders = [(AppleFrameworkLoader, [
suffix.replace(".so", ".fwork")
for suffix in _imp.extension_suffixes()
])]
else:
extension_loaders = []
extension_loaders.append((ExtensionFileLoader, _imp.extension_suffixes()))
extension_loaders = []
if hasattr(_imp, 'create_dynamic'):
if sys.platform in {"ios", "tvos", "watchos"}:
extension_loaders = [(AppleFrameworkLoader, [
suffix.replace(".so", ".fwork")
for suffix in _imp.extension_suffixes()
])]
extension_loaders.append((ExtensionFileLoader, _imp.extension_suffixes()))
source = SourceFileLoader, SOURCE_SUFFIXES
bytecode = SourcelessFileLoader, BYTECODE_SUFFIXES
return extension_loaders + [source, bytecode]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Building with ``HAVE_DYNAMIC_LOADING`` now works as well as it did in 3.12.
Existing deficiences will be addressed separately.
(See https://github.com/python/cpython/issues/122950.)
12 changes: 8 additions & 4 deletions Python/importdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#include "pycore_pystate.h"
#include "pycore_runtime.h"

#include "pycore_importdl.h"

/* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is
supported on this platform. configure will then compile and link in one
of the dynload_*.c files, as appropriate. We will call a function in
those modules to get a function pointer to the module's init function.
*/
#ifdef HAVE_DYNAMIC_LOADING

#include "pycore_importdl.h"

#ifdef MS_WINDOWS
extern dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
const char *shortname,
Expand All @@ -28,6 +28,8 @@ extern dl_funcptr _PyImport_FindSharedFuncptr(const char *prefix,
const char *pathname, FILE *fp);
#endif

#endif /* HAVE_DYNAMIC_LOADING */


/***********************************/
/* module info to use when loading */
Expand Down Expand Up @@ -205,6 +207,7 @@ _Py_ext_module_loader_info_init_for_core(
return 0;
}

#ifdef HAVE_DYNAMIC_LOADING
int
_Py_ext_module_loader_info_init_from_spec(
struct _Py_ext_module_loader_info *p_info,
Expand All @@ -226,6 +229,7 @@ _Py_ext_module_loader_info_init_from_spec(
Py_DECREF(filename);
return err;
}
#endif /* HAVE_DYNAMIC_LOADING */


/********************************/
Expand Down Expand Up @@ -372,6 +376,7 @@ _Py_ext_module_loader_result_apply_error(
/* getting/running the module init function */
/********************************************/

#ifdef HAVE_DYNAMIC_LOADING
PyModInitFunction
_PyImport_GetModInitFunc(struct _Py_ext_module_loader_info *info,
FILE *fp)
Expand Down Expand Up @@ -406,6 +411,7 @@ _PyImport_GetModInitFunc(struct _Py_ext_module_loader_info *info,

return (PyModInitFunction)exportfunc;
}
#endif /* HAVE_DYNAMIC_LOADING */

int
_PyImport_RunModInitFunc(PyModInitFunction p0,
Expand Down Expand Up @@ -513,5 +519,3 @@ _PyImport_RunModInitFunc(PyModInitFunction p0,
p_res->err = &p_res->_err;
return -1;
}

#endif /* HAVE_DYNAMIC_LOADING */
9 changes: 9 additions & 0 deletions Tools/build/check_extension_modules.py