Skip to content

Commit 423cfed

Browse files
jere8184heinezen
authored andcommitted
working wondows debug build
1 parent cfc21ff commit 423cfed

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

buildsystem/cythonize.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,32 @@ def cythonize_wrapper(modules, **kwargs):
8888
with redirect_stdout(cython_filter):
8989
if src_modules:
9090
cythonize(src_modules, **kwargs)
91+
windows_include_python_debug_build_wrapper(src_modules, bin_dir)
9192

9293
if bin_modules:
9394
os.chdir(bin_dir)
9495
cythonize(bin_modules, **kwargs)
96+
windows_include_python_debug_build_wrapper(bin_modules, bin_dir)
9597
os.chdir(src_dir)
9698

9799

100+
def windows_include_python_debug_build_wrapper(modules, path):
101+
for module in modules:
102+
module = str(module)
103+
if (path):
104+
module = path + "\\" + module
105+
module = module.removesuffix(".py").removesuffix(".pyx")
106+
module = module + ".cpp"
107+
with open(module, "r") as file:
108+
text = file.read()
109+
text = text.replace("#include \"Python.h\"",
110+
"#ifdef _DEBUG\n#define _DEBUG_WAS_DEFINED\n#undef _DEBUG\n#endif\n\
111+
#include \"Python.h\"\n#ifdef _DEBUG_WAS_DEFINED\n#define _DEBUG\n\
112+
#undef _DEBUG_WAS_DEFINED\n#endif", 1)
113+
with open(module, "w") as file:
114+
file.write(text)
115+
116+
98117
def main():
99118
""" CLI entry point """
100119
cli = argparse.ArgumentParser()

buildsystem/python.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ function(add_cython_modules)
128128
if(MINGW)
129129
set_target_properties("${TARGETNAME}" PROPERTIES LINK_FLAGS "-municode")
130130
endif()
131-
132-
target_link_libraries("${TARGETNAME}" PRIVATE ${PYEXT_LIBRARY})
131+
target_link_libraries("${TARGETNAME}" PRIVATE C:/vcpkg/installed/x64-windows/lib/python311.lib)
133132
else()
134133
set_property(GLOBAL APPEND PROPERTY SFT_CYTHON_MODULES "${source}")
135134
add_library("${TARGETNAME}" MODULE "${CPPNAME}")
@@ -140,7 +139,7 @@ function(add_cython_modules)
140139
)
141140

142141
if(WIN32)
143-
target_link_libraries("${TARGETNAME}" PRIVATE ${PYEXT_LIBRARY})
142+
target_link_libraries("${TARGETNAME}" PRIVATE C:/vcpkg/installed/x64-windows/lib/python311.lib)
144143
endif()
145144
endif()
146145

@@ -514,6 +513,7 @@ function(python_finalize)
514513
${INPLACEMODULES_LISTFILE}
515514
"$<CONFIG>"
516515
)
516+
message(hello jeremiah, ${INPLACEMODULES_LISTFILE})
517517
set(INPLACEMODULES_TIMEFILE "${CMAKE_BINARY_DIR}/py/inplacemodules_timefile")
518518
add_custom_command(OUTPUT "${INPLACEMODULES_TIMEFILE}"
519519
COMMAND ${INPLACEMODULES_INVOCATION}

0 commit comments

Comments
 (0)