@@ -370,21 +370,55 @@ internal static async Task InstallPythonAsync()
370370
371371 Assembly wheelsAssembly = context . LoadFromAssemblyPath ( Path . Join ( Path . GetDirectoryName ( assembly . Location ) , "DSPythonNet3Wheels.dll" ) ) ;
372372
373+ string sitePkgsPath = Path . Combine ( Python . Included . Installer . EmbeddedPythonHome , "Lib" , "site-packages" ) ;
374+ Directory . CreateDirectory ( sitePkgsPath ) ;
375+
373376 List < string > pipWheelInstall = new List < string > ( ) ;
374- await Task . WhenAll ( wheelsAssembly . GetManifestResourceNames ( ) . Where ( x =>
377+
378+ // Extract noo-pip wheels directly from the resource stream
379+ foreach ( var resName in wheelsAssembly . GetManifestResourceNames ( ) )
375380 {
376- bool isWheel = x . Contains ( ".whl" ) ;
377- if ( isWheel && x . Contains ( "pywin32-" ) )
381+ bool isWheel = resName . EndsWith ( ".whl" ) ;
382+ if ( ! isWheel ) continue ;
383+
384+ if ( resName . Contains ( "pywin32-" ) )
378385 {
379- pipWheelInstall . Add ( x ) ;
380- return false ;
386+ pipWheelInstall . Add ( resName ) ;
387+ continue ;
381388 }
382389
383- return isWheel ;
384- } ) . Select ( wheel => Python . Included . Installer . InstallWheel ( wheelsAssembly , wheel ) ) ) . ConfigureAwait ( false ) ;
390+ using ( var stream = wheelsAssembly . GetManifestResourceStream ( resName ) )
391+ {
392+ if ( stream == null || stream . Length == 0 )
393+ {
394+ continue ;
395+ }
396+
397+ using ( var zip = new System . IO . Compression . ZipArchive ( stream , System . IO . Compression . ZipArchiveMode . Read , false ) )
398+ {
399+ foreach ( var entry in zip . Entries )
400+ {
401+ if ( string . IsNullOrEmpty ( entry . Name ) ) continue ;
402+
403+ var destPath = Path . Combine ( sitePkgsPath , entry . FullName . Replace ( '/' , Path . DirectorySeparatorChar ) ) ;
404+ var destDir = Path . GetDirectoryName ( destPath ) ;
405+ if ( ! string . IsNullOrEmpty ( destDir ) )
406+ {
407+ Directory . CreateDirectory ( destDir ) ;
408+ }
409+
410+ using ( var inStream = entry . Open ( ) )
411+ using ( var outStream = new FileStream ( destPath , FileMode . Create , FileAccess . Write , FileShare . None ) )
412+ {
413+ await inStream . CopyToAsync ( outStream ) . ConfigureAwait ( false ) ;
414+ }
415+ }
416+ }
417+ }
418+ }
385419
386420 foreach ( var pipWheelResource in pipWheelInstall )
387- {
421+ {
388422 var pipWheelName = pipWheelResource . Remove ( 0 , "DSPythonNet3Wheels.Resources." . Count ( ) ) ;
389423 string wheelPath = Path . Combine ( Python . Included . Installer . EmbeddedPythonHome , "Lib" , pipWheelName ) ;
390424 using ( Stream ? stream = wheelsAssembly . GetManifestResourceStream ( pipWheelResource ) )
0 commit comments