2020HERE = os .path .dirname (os .path .abspath (__file__ ))
2121DPI_BRIDGE_DIR = os .path .join (HERE , "dpi_bridge" )
2222NATIVE_SRC_DIR = os .path .join ("src" , "native" )
23+ DPI_INCLUDE_PLACEHOLDER = "__DM_DPI_INCLUDE_PLACEHOLDER__"
2324
2425
2526def read_project_version () -> str :
@@ -81,9 +82,6 @@ def find_dpi_include():
8182 "See README.md for details."
8283 )
8384
84-
85- DPI_INCLUDE_DIR = find_dpi_include ()
86-
8785# Macros
8886define_macros = []
8987if struct .calcsize ("P" ) == 8 :
@@ -101,6 +99,12 @@ class build_ext(_build_ext):
10199 """Custom build_ext that builds the Go bridge library before compiling."""
102100
103101 def run (self ):
102+ dpi_include_dir = find_dpi_include ()
103+ for ext in self .extensions :
104+ ext .include_dirs = [
105+ dpi_include_dir if d == DPI_INCLUDE_PLACEHOLDER else d
106+ for d in ext .include_dirs
107+ ]
104108 if not os .environ .get ("DMPYTHON_SKIP_GO_BUILD" ):
105109 self ._build_go_bridge ()
106110 super ().run ()
@@ -146,7 +150,7 @@ def _build_go_bridge(self):
146150extension = Extension (
147151 name = "dmPython" ,
148152 sources = C_SOURCES ,
149- include_dirs = [DPI_INCLUDE_DIR , os .path .join (HERE , NATIVE_SRC_DIR )],
153+ include_dirs = [DPI_INCLUDE_PLACEHOLDER , os .path .join (HERE , NATIVE_SRC_DIR )],
150154 library_dirs = [DPI_BRIDGE_DIR ],
151155 libraries = ["dmdpi" ],
152156 define_macros = define_macros ,
0 commit comments