@@ -890,7 +890,61 @@ def hack_project_files(
890
890
)
891
891
892
892
893
- PYPORT_EXPORT_SEARCH = b"""
893
+ PYPORT_EXPORT_SEARCH_NEW = b"""
894
+ #if defined(__CYGWIN__)
895
+ # define HAVE_DECLSPEC_DLL
896
+ #endif
897
+
898
+ /* only get special linkage if built as shared or platform is Cygwin */
899
+ #if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
900
+ # if defined(HAVE_DECLSPEC_DLL)
901
+ # if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
902
+ # define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
903
+ # define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE
904
+ /* module init functions inside the core need no external linkage */
905
+ /* except for Cygwin to handle embedding */
906
+ # if defined(__CYGWIN__)
907
+ # define PyMODINIT_FUNC __declspec(dllexport) PyObject*
908
+ # else /* __CYGWIN__ */
909
+ # define PyMODINIT_FUNC PyObject*
910
+ # endif /* __CYGWIN__ */
911
+ # else /* Py_BUILD_CORE */
912
+ /* Building an extension module, or an embedded situation */
913
+ /* public Python functions and data are imported */
914
+ /* Under Cygwin, auto-import functions to prevent compilation */
915
+ /* failures similar to those described at the bottom of 4.1: */
916
+ /* http://docs.python.org/extending/windows.html#a-cookbook-approach */
917
+ # if !defined(__CYGWIN__)
918
+ # define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
919
+ # endif /* !__CYGWIN__ */
920
+ # define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
921
+ /* module init functions outside the core must be exported */
922
+ # if defined(__cplusplus)
923
+ # define PyMODINIT_FUNC extern "C" __declspec(dllexport) PyObject*
924
+ # else /* __cplusplus */
925
+ # define PyMODINIT_FUNC __declspec(dllexport) PyObject*
926
+ # endif /* __cplusplus */
927
+ # endif /* Py_BUILD_CORE */
928
+ # endif /* HAVE_DECLSPEC_DLL */
929
+ #endif /* Py_ENABLE_SHARED */
930
+
931
+ /* If no external linkage macros defined by now, create defaults */
932
+ #ifndef PyAPI_FUNC
933
+ # define PyAPI_FUNC(RTYPE) RTYPE
934
+ #endif
935
+ #ifndef PyAPI_DATA
936
+ # define PyAPI_DATA(RTYPE) extern RTYPE
937
+ #endif
938
+ #ifndef PyMODINIT_FUNC
939
+ # if defined(__cplusplus)
940
+ # define PyMODINIT_FUNC extern "C" PyObject*
941
+ # else /* __cplusplus */
942
+ # define PyMODINIT_FUNC PyObject*
943
+ # endif /* __cplusplus */
944
+ #endif
945
+ """
946
+
947
+ PYPORT_EXPORT_SEARCH_OLD = b"""
894
948
#if defined(__CYGWIN__)
895
949
# define HAVE_DECLSPEC_DLL
896
950
#endif
@@ -978,7 +1032,14 @@ def hack_source_files(source_path: pathlib.Path, static: bool):
978
1032
# dynamically linked. This is a useful property to have.
979
1033
if static :
980
1034
pyport_h = source_path / "Include" / "pyport.h"
981
- static_replace_in_file (pyport_h , PYPORT_EXPORT_SEARCH , PYPORT_EXPORT_REPLACE )
1035
+ try :
1036
+ static_replace_in_file (
1037
+ pyport_h , PYPORT_EXPORT_SEARCH_NEW , PYPORT_EXPORT_REPLACE
1038
+ )
1039
+ except NoSearchStringError :
1040
+ static_replace_in_file (
1041
+ pyport_h , PYPORT_EXPORT_SEARCH_OLD , PYPORT_EXPORT_REPLACE
1042
+ )
982
1043
983
1044
# Modules/_winapi.c and Modules/overlapped.c both define an
984
1045
# ``OverlappedType`` symbol. We rename one to make the symbol conflict
0 commit comments