@@ -344,7 +344,36 @@ internal static async Task InstallPythonAsync()
344344 AssemblyLoadContext context = AssemblyLoadContext . GetLoadContext ( assembly ) ?? throw new Exception ( "Can't get assembly context." ) ;
345345
346346 Assembly wheelsAssembly = context . LoadFromAssemblyPath ( Path . Join ( Path . GetDirectoryName ( assembly . Location ) , "DSPythonNet3Wheels.dll" ) ) ;
347- await Task . WhenAll ( wheelsAssembly . GetManifestResourceNames ( ) . Where ( x => x . Contains ( ".whl" ) ) . Select ( wheel => Python . Included . Installer . InstallWheel ( wheelsAssembly , wheel ) ) ) . ConfigureAwait ( false ) ;
347+
348+ List < string > pipWheelInstall = new List < string > ( ) ;
349+ await Task . WhenAll ( wheelsAssembly . GetManifestResourceNames ( ) . Where ( x =>
350+ {
351+ bool isWheel = x . Contains ( ".whl" ) ;
352+ if ( isWheel && x . Contains ( "pywin32-" ) )
353+ {
354+ pipWheelInstall . Add ( x ) ;
355+ return false ;
356+ }
357+
358+ return isWheel ;
359+ } ) . Select ( wheel => Python . Included . Installer . InstallWheel ( wheelsAssembly , wheel ) ) ) . ConfigureAwait ( false ) ;
360+
361+ foreach ( var pipWheelResource in pipWheelInstall )
362+ {
363+ var pipWheelName = pipWheelResource . Remove ( 0 , "DSPythonNet3Wheels.Resources." . Count ( ) ) ;
364+ string wheelPath = Path . Combine ( Python . Included . Installer . EmbeddedPythonHome , "Lib" , pipWheelName ) ;
365+ using ( Stream ? stream = wheelsAssembly . GetManifestResourceStream ( pipWheelResource ) )
366+ {
367+ using ( FileStream destination = new FileStream ( wheelPath , FileMode . Create ) )
368+ {
369+ stream ? . CopyTo ( destination ) ;
370+ }
371+ }
372+
373+ string cmdToExecute = $ "python -m pip install \" Lib\\ { pipWheelName } \" ";
374+ await Python . Deployment . Installer . RunCommand ( cmdToExecute , CancellationToken . None ) ;
375+ File . Delete ( wheelPath ) ;
376+ }
348377
349378 isPythonInstalled = true ;
350379 }
0 commit comments