@@ -163,6 +163,27 @@ public override void Run(BuildContext context)
163163
164164 context . CopyFiles ( dylibFiles , targetBuildDir . FullPath ) ;
165165
166+ // for Python, also copy the entire Python runtime (lib, include, etc.)
167+ if ( projectItem . DotNetNativeName == "Python" )
168+ {
169+ // Copy all Python runtime files and directories
170+ var pythonRuntimePattern = $ "{ backendPluginsRoot . FullPath } /**/*";
171+ var allPythonFiles = context . GetFiles (
172+ new GlobPattern ( pythonRuntimePattern ) ,
173+ new GlobberSettings { IsCaseSensitive = false } ) ;
174+
175+ foreach ( var file in allPythonFiles )
176+ {
177+ var relativePath = file . FullPath . Substring ( backendPluginsRoot . FullPath . Length + 1 ) ;
178+ var targetFile = System . IO . Path . Combine ( targetBuildDir . FullPath , relativePath ) ;
179+ var targetFileDir = System . IO . Path . GetDirectoryName ( targetFile ) ;
180+ Directory . CreateDirectory ( targetFileDir ) ;
181+ context . CopyFile ( file , targetFile ) ;
182+ }
183+
184+ context . Log . Information ( $ "Copied Python runtime files from '{ backendPluginsRoot . FullPath } ' to '{ targetBuildDir . FullPath } '") ;
185+ }
186+
166187 // for NodeJS, also copy libnode*.dylib
167188 if ( projectItem . DotNetNativeName == "NodeJS" )
168189 {
@@ -251,7 +272,24 @@ public override void Run(BuildContext context)
251272 Directory . CreateDirectory ( targetDirectory . FullPath ) ;
252273
253274 var files = context . GetFiles ( new GlobPattern ( $ "{ nativeAssetsPath . FullPath } /**/*") ) ;
254- context . CopyFiles ( files , targetDirectory . FullPath ) ;
275+
276+ // For Python, we need to preserve directory structure
277+ if ( projectItem . DotNetNativeName == "Python" )
278+ {
279+ foreach ( var file in files )
280+ {
281+ var relativePath = file . FullPath . Substring ( nativeAssetsPath . FullPath . Length + 1 ) ;
282+ var targetFile = System . IO . Path . Combine ( targetDirectory . FullPath , relativePath ) ;
283+ var targetFileDir = System . IO . Path . GetDirectoryName ( targetFile ) ;
284+ Directory . CreateDirectory ( targetFileDir ) ;
285+ context . CopyFile ( file , targetFile ) ;
286+ }
287+ context . Log . Information ( $ "Copied Python runtime with directory structure preserved to '{ targetDirectory . FullPath } '") ;
288+ }
289+ else
290+ {
291+ context . CopyFiles ( files , targetDirectory . FullPath ) ;
292+ }
255293 }
256294 }
257295}
0 commit comments