Building of IronPython2 Beta2 (Community Edition)

IronPython2B2

This page documents the building of IronPython2 Beta2, Community Edition. See IronPython for details on installing IP2B2.

Issues

There is one place that required a change in the MS code, but with a little tweak, it now builds and runs. The problem:

  1. mapSite in Src/IronPython/Runtime/Builtin.cs

There were compile issues with Src/IronPython/Runtime/Builtin.cs around mapSite. I added the following to try to get it to compile (note DSB HACK). The complaint was that mapSite was uninitialized. So I threw an error in one spot, and initialized it to a guess in the other:

public static List map(params object[] param) {

            ....

            if (param.Length == 2) {
                DynamicSite<object, object, object> mapSite;
                if (func != null) mapSite = CallSiteFactory.CreateSimpleCallSite<object, object, object>(DefaultContext.DefaultPythonBinder);
		// DSB HACK:
		else throw PythonOps.TypeError("function to map should not be null");

            ....

                    if (func != null) {
			// DSB HACK:
			mapSite = CallSiteFactory.CreateSimpleCallSite<object, object[], object>(DefaultContext.DefaultPythonBinder);
                        // splat call w/ args, can't use site here yet...
			if (!mapSite.IsInitialized) {
			    mapSite.EnsureInitialized(
						      CallAction.Make(DefaultContext.DefaultPythonBinder, new CallSignature(ArgumentKind.List))
						      );
			}
             ....

Patches

  • IPCE/fepy/patches/2.0b2
    • IPCE/fepy/patches/2.0b2/series
    • IPCE/fepy/patches/2.0b2/patch-console
    • IPCE/fepy/patches/2.0b2/patch-dictproxy
    • IPCE/fepy/patches/2.0b2/patch-nant-build
    • IPCE/fepy/patches/2.0b2/patch-option-v

IPCE/fepy/patches/2.0b2/series:

patch-nant-build
patch-console
patch-dictproxy
patch-option-v

IPCE/fepy/patches/2.0b2/patch-console:

Index: IronPython-2.0B2/Src/Microsoft.Scripting/Hosting/Shell/BasicConsole.cs
===================================================================
--- IronPython-2.0B2.orig/Src/Microsoft.Scripting/Hosting/Shell/BasicConsole.cs 
2008-03-06 13:24:46.000000000 +0900
+++ IronPython-2.0B2/Src/Microsoft.Scripting/Hosting/Shell/BasicConsole.cs      
2008-04-27 23:59:15.000000000 +0900
@@ -94,16 +94,8 @@
         }
 
         protected void WriteColor(TextWriter output, string str, ConsoleColor c
) {
-#if !SILVERLIGHT // Console.ForegroundColor
-            ConsoleColor origColor = Console.ForegroundColor;
-            Console.ForegroundColor = c;
-#endif
             output.Write(str);
             output.Flush();
-
-#if !SILVERLIGHT // Console.ForegroundColor
-            Console.ForegroundColor = origColor;
-#endif
         }
 
         #region IConsole Members
Index: IronPython-2.0B2/Src/Microsoft.Scripting/Hosting/Shell/ConsoleOptions.cs
===================================================================
--- IronPython-2.0B2.orig/Src/Microsoft.Scripting/Hosting/Shell/ConsoleOptions.c
s       2008-03-06 13:24:46.000000000 +0900
+++ IronPython-2.0B2/Src/Microsoft.Scripting/Hosting/Shell/ConsoleOptions.cs    
2008-04-27 23:59:15.000000000 +0900
@@ -31,7 +31,7 @@
         private bool _introspection;
         private bool _autoIndent;
         private bool _handleExceptions = true;
-        private bool _tabCompletion;
+        private bool _tabCompletion = true;
         private bool _colorfulConsole;
         private bool _printUsageAndExit;

IPCE/fepy/patches/2.0b2/patch-dictproxy:

Index: IronPython-2.0B2/Src/IronPython/Runtime/Types/DictProxy.cs
===================================================================
--- IronPython-2.0B2.orig/Src/IronPython/Runtime/Types/DictProxy.cs     2008-04-28 04:00:58.000000000 +0900
+++ IronPython-2.0B2/Src/IronPython/Runtime/Types/DictProxy.cs  2008-04-28 04:04:23.000000000 +0900
@@ -58,6 +58,17 @@
             return TryGetValue(key, out dummy);
         }
 
+        public object get(object key) {
+            return get(key, null);
+        }
+
+        public object get(object key, object defaultValue) {
+            object res;
+            if (TryGetValue(key, out res))
+                return res;
+            return defaultValue;
+        }
+
         public object keys(CodeContext context) {
             return new List(_dt.GetMemberDictionary(context).Keys);
         }

IPCE/IronPython-2.0B2/IronPython.build:

<!-- vim:set ft=xml: -->
<project name="IronPython">
    <property name="warn" value="4"/>
    <resgen input="Microsoft.Scripting.Core/Microsoft.Scripting.txt"
        output="Microsoft.Scripting.Core/Microsoft.Scripting.Core.resources"/>
    <csc target="library" output="Microsoft.Scripting.Core.dll"
        warninglevel="${warn}">
        <sources>
            <include name="Microsoft.Scripting.Core/**/*.cs"/>
        </sources>
        <resources dynamicprefix="true" basedir="Microsoft.Scripting.Core">
            <include name="Microsoft.Scripting.Core.resources"/>
        </resources>
        <references>
            <include name="System.Configuration.dll"/>
        </references>
    </csc>
    <csc target="library" output="Microsoft.Scripting.dll"
        warninglevel="${warn}">
        <sources>
            <include name="Microsoft.Scripting/**/*.cs"/>
        </sources>
        <resources dynamicprefix="true">
            <include name="Microsoft.Scripting/**/*.resx"/>
        </resources>
        <references>
            <include name="System.Configuration.dll"/>
            <include name="Microsoft.Scripting.Core.dll"/>
        </references>
    </csc>
    <csc target="library" output="IronPython.dll"
        warninglevel="${warn}">
        <sources>
            <include name="IronPython/**/*.cs"/>
        </sources>
        <resources dynamicprefix="true">
            <include name="IronPython/**/*.resx"/>
        </resources>
        <references>
            <include name="Microsoft.Scripting.dll"/>
            <include name="Microsoft.Scripting.Core.dll"/>
        </references>
    </csc>
    <csc target="library" output="IronPython.Modules.dll"
        warninglevel="${warn}">
        <sources>
            <include name="IronPython.Modules/**/*.cs"/>
        </sources>
        <references>
            <include name="Microsoft.Scripting.dll"/>
            <include name="Microsoft.Scripting.Core.dll"/>
            <include name="IronPython.dll"/>
        </references>
    </csc>
    <csc target="library" output="IronPythonTest.dll"
        noconfig="true" warninglevel="${warn}">
        <sources>
            <include name="IronPythonTest/**/*.cs"/>
        </sources>
        <references>
            <include name="System.dll"/>
            <include name="System.Xml.dll"/>
            <include name="Microsoft.Scripting.dll"/>
            <include name="Microsoft.Scripting.Core.dll"/>
            <include name="IronPython.dll"/>
        </references>
    </csc>
    <csc target="exe" output="ipy.exe"
        warninglevel="${warn}">
        <sources>
            <include name="IronPythonConsole/**/*.cs"/>
        </sources>
        <references>
            <include name="Microsoft.Scripting.dll"/>
            <include name="Microsoft.Scripting.Core.dll"/>
            <include name="IronPython.dll"/>
        </references>
    </csc>
    <csc target="winexe" output="ipyw.exe" define="IRONPYTHON_WINDOW"
        warninglevel="${warn}">
        <sources>
            <include name="IronPythonConsole/**/*.cs"/>
        </sources>
        <references>
            <include name="Microsoft.Scripting.dll"/>
            <include name="Microsoft.Scripting.Core.dll"/>
            <include name="IronPython.dll"/>
        </references>
    </csc>
</project>

IPCE/fepy/patches/2.0b2/patch-option-v:

Index: IronPython-2.0B2/Src/IronPython/Runtime/Importer.cs
===================================================================
--- IronPython-2.0B2.orig/Src/IronPython/Runtime/Importer.cs    2008-04-28 04:12:46.000000000 +0900
+++ IronPython-2.0B2/Src/IronPython/Runtime/Importer.cs 2008-04-28 04:17:26.000000000 +0900
@@ -744,7 +744,11 @@
 
         private static PythonModule/*!*/ LoadFromSourceUnit(CodeContext/*!*/ context, SourceUnit/*!*/ sourceCode, string/*!*/ name, string/*!*/ path) {
             Assert.NotNull(sourceCode, name, path);
-            return PythonContext.GetContext(context).CompileModule(path, name, sourceCode, ModuleOptions.Initialize | ModuleOptions.Optimized | ModuleOptions.PublishModule, false);
+            PythonContext pc = PythonContext.GetContext(context);
+            if (pc.DomainManager.GlobalOptions.Verbose)
+                Console.WriteLine("import {0}", name);
+
+            return pc.CompileModule(path, name, sourceCode, ModuleOptions.Initialize | ModuleOptions.Optimized | ModuleOptions.PublishModule, false);
         }
     }
 }
Scroll to Top