From 573efe12c264b65774b80235dca1b2f9992d41e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lozier?= Date: Fri, 16 Sep 2022 22:19:12 -0400 Subject: [PATCH] Embed missing assemblies with ipyc --- Src/IronPython/IronPython.csproj | 2 +- Src/IronPythonCompiler/Program.cs | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Src/IronPython/IronPython.csproj b/Src/IronPython/IronPython.csproj index ff02ed6ed..2b3bfe40c 100644 --- a/Src/IronPython/IronPython.csproj +++ b/Src/IronPython/IronPython.csproj @@ -31,7 +31,7 @@ - + diff --git a/Src/IronPythonCompiler/Program.cs b/Src/IronPythonCompiler/Program.cs index 489b8346f..115b8f502 100644 --- a/Src/IronPythonCompiler/Program.cs +++ b/Src/IronPythonCompiler/Program.cs @@ -5,20 +5,19 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using IronPython.Runtime; -using IronPython.Runtime.Operations; -using IronPython.Hosting; +using System.Resources; + using IKVM.Reflection; using IKVM.Reflection.Emit; -using System.Resources; -using Type = IKVM.Reflection.Type; +using IronPython.Hosting; +using IronPython.Runtime; +using IronPython.Runtime.Operations; -using Microsoft.Scripting.Runtime; using Microsoft.Scripting.Hosting; -using Microsoft.Scripting.Hosting.Providers; +using Microsoft.Scripting.Runtime; + +using Type = IKVM.Reflection.Type; namespace IronPythonCompiler { @@ -62,9 +61,20 @@ private static void GenerateExe(Config config) { ConsoleOps.Info("Generating stand alone executable"); config.Embed = true; + var embedAssemblies = new HashSet { + // DLR + "Microsoft.Dynamic", + "Microsoft.Scripting", + // System.Memory + "System.Buffers", + "System.Memory", + "System.Numerics.Vectors", + "System.Runtime.CompilerServices.Unsafe", + }; + foreach (var a in System.AppDomain.CurrentDomain.GetAssemblies()) { var n = new AssemblyName(a.FullName); - if (!a.IsDynamic && a.EntryPoint == null && (n.Name.StartsWith("IronPython", StringComparison.Ordinal) || n.Name == "Microsoft.Dynamic" || n.Name == "Microsoft.Scripting")) { + if (!a.IsDynamic && a.EntryPoint == null && (n.Name.StartsWith("IronPython", StringComparison.Ordinal) || embedAssemblies.Contains(n.Name))) { ConsoleOps.Info($"\tEmbedded {n.Name} {n.Version}"); var f = new FileStream(a.Location, FileMode.Open, FileAccess.Read); mb.DefineManifestResource("Dll." + n.Name, f, IKVM.Reflection.ResourceAttributes.Public);