PageRenderTime 26ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/DLR_Main/Languages/IronPython/Readme.html

https://bitbucket.org/mdavid/dlr
HTML | 196 lines | 186 code | 10 blank | 0 comment | 0 complexity | b3a65ac3904651405362bb23710955cf MD5 | raw file
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  5. <title>IronPython ReadMe</title>
  6. </head>
  7. <body style="color: #000000">
  8. <h1></h1>
  9. <h1>
  10. </h1>
  11. <h1>
  12. IronPython 0.9</h1>
  13. <p>
  14. IronPython is a new implementation of the Python programming language on .NET.&nbsp; The .NET Framework
  15. is a managed programming model for Windows; Microsoft standardized part of it in&nbsp;<a href="http://www.ecma-international.org/">ECMA</a>
  16. years ago as the
  17. <a href="http://www.ecma-international.org/publications/standards/Ecma-335.htm">Common Language Infrastructure</a> and
  18. <a href="http://www.ecma-international.org/publications/standards/Ecma-334.htm">C# Language Specification</a>
  19. standards.</p>
  20. <p>
  21. IronPython is fast - up to 37% faster than Python-2.6 on the standard
  22. PyStone benchmark.&nbsp; It supports an interactive interpreter
  23. with fully dynamic compilation.&nbsp; It is well integrated with
  24. the rest of the framework and makes the whole .NET Framework class
  25. library easily available to Python
  26. programmers.</p>
  27. <p>
  28. The best place to learn more about IronPython is the
  29. <a href="http://www.ironpython.net">official webiste</a>.&nbsp;
  30. There you'll find links to our
  31. <a href="http://www.codeplex.com/ironpython">CodePlex site</a> which
  32. includes IronPython sources, binaries, and samples<span style="color: #000000">.&nbsp;
  33. You can also file bugs and generally interact with the
  34. IronPython team through this shared project site.&nbsp; Finally, there's a
  35. mailing list you can join for discussing issues and releases if you
  36. like.</span></p>
  37. <p>
  38. There's a good introductory tutorial at
  39. <a href="Tutorial/Tutorial.htm">IronPython Tutorial</a>.</p>
  40. <p>
  41. IronPython has a high degree of compatibility with CPython, but
  42. there are some differences. See
  43. <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython&title=Differences">IronPython Differences</a> document for details.</p>
  44. <p>
  45. IronPython 0.9 is suitable for building Python applications where you want
  46. to make use of .NET Framework and pure python modules. There are still some
  47. missing standard CPython libraries (See
  48. <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython&title=Differences">IronPython Differences</a> for details.), and there are some known issues
  49. with the IronPython implementation
  50. (see <a href="http://www.codeplex.com/ironpython">
  51. www.codeplex.com/ironpython</a>).</p>
  52. <p>
  53. &nbsp;</p>
  54. <h2>
  55. Prerequisites</h2>
  56. <p>
  57. To run, IronPython 0.9 requires .NET Framework version
  58. 4.0 to be installed
  59. on your system. You can install the latest version from Microsoft:</p>
  60. <ul>
  61. <li>
  62. <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992&amp;displaylang=en">Microsoft .NET Framework Version
  63. 4.0</a></li></ul>
  64. <p>
  65. IronPython should also run on any platform that implements the CLI specification v4.0.</p>
  66. <p>
  67. There are <a href="#BuilFromSource">more prerequisites</a> if you want to build IronPython from source.</p>
  68. <p>
  69. &nbsp;</p>
  70. <h2>
  71. Running IronPython</h2>
  72. <p>If you did not download the binaries, you'll need to
  73. <a href="#BuilFromSource">build IronPython</a> first.&nbsp; After building
  74. IronPython or unpacking the binary distribution, you can complete the installation by
  75. adding the IronPython installation directory to your PATH.&nbsp; To test the installation, you
  76. should launch the interactive interpreter as shown below:</p>
  77. <blockquote>
  78. <pre>C:\IronPython&gt;ipy
  79. IronPython 2.7.0 on .NET 4.0.30319.1
  80. Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  81. &gt;&gt;&gt; 2+2
  82. 4</pre>
  83. </blockquote>
  84. <p>You can use IronPython to run Python scripts by passing the script name on
  85. the command-line just as with standard Python.&nbsp; If hello.py had the
  86. displayed contents, the following ipy command line would run it:</p>
  87. <blockquote>
  88. <pre>Hello.py:
  89. for i in xrange(3):
  90. print "Hello World"
  91. C:\IronPython&gt;ipy Hello.py
  92. Hello World
  93. Hello World
  94. Hello World
  95. </pre>
  96. </blockquote>
  97. This simple example shows how you can start using WinForms from IronPython:
  98. <blockquote>
  99. <pre>C:\IronPython&gt;ipy
  100. IronPython 2.7.0 on .NET 4.0.30319.1
  101. Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  102. &gt;&gt;&gt; import clr
  103. &gt;&gt;&gt; clr.AddReference(&quot;System.Windows.Forms&quot;)
  104. &gt;&gt;&gt; import System.Windows.Forms as WinForms
  105. &gt;&gt;&gt; WinForms.MessageBox.Show(&quot;Hello&quot;, &quot;Hello World&quot;)
  106. OK
  107. </pre>
  108. </blockquote>
  109. <p>For more information on the clr.AddReference function, see the
  110. <a href="Tutorial/Tutorial.htm#T1.3">Loading .NET Libraries</a> exercise in the
  111. <a href="Tutorial/Tutorial.htm">IronPython Tutorial</a><span style="color: #000000">,
  112. which has many examples of using IronPython in various ways.</span></p>
  113. <p>&nbsp;</p>
  114. <h2><a name="silverlight"></a>IronPython in Silverlight</h2>
  115. <div style="border-left: 10px solid yellow; padding: 10px;">
  116. <h3>ATTENTION!</h3>
  117. <p>
  118. See <a href="http://ironpython.net/browser/" target="_blank">ironpython.net/browser</a>
  119. for the most up-to-date information on using Python in the browser with Silverlight.
  120. For example, this HTML page hosts Silverlight to run Python code, and requires no extra
  121. dependencies:
  122. </p>
  123. <blockquote><pre>&lt;html&gt;
  124. &lt;head&gt;
  125. &lt;script type="text/javascript"
  126. src="http://gestalt.ironpython.net/dlr-latest.js"&gt;&lt;/script&gt;
  127. &lt;/head&gt;
  128. &lt;body&gt;
  129. &lt;div id="message"&gt;Loading ...&lt;/div&gt;
  130. &lt;script type="text/python"&gt;
  131. document.message.innerHTML = "Hello from python!"
  132. def on_click(obj, args):
  133. obj.innerHTML = "Clicked!"
  134. document.message.events.onclick += on_click
  135. &lt;/script&gt;
  136. &lt;/body&gt;
  137. &lt;/html&gt;</pre></blockquote>
  138. <p>
  139. Keep in mind the information, binaries, and examples in this package
  140. will still help you build Silverlight applications with IronPython, but
  141. using HTML script-tags is the preferred model going forward; the
  142. ways described here will be deprecated in a future release.
  143. </p>
  144. </div>
  145. <h3>Generating an application</h3>
  146. <blockquote><pre>script\sl python MyApp</pre></blockquote>
  147. <p>Will create "MyApp" in the current directory.</p>
  148. <p>For more information on the "server" script, run <code>script\server</code></p>
  149. <h3>Running an app</h3>
  150. <blockquote><pre>script\server /b:MyApp\index.html</pre></blockquote>
  151. <p>This will launch the default browesr pointed at the application.</p>
  152. <p>&nbsp;</p>
  153. <h2><a name="BuilFromSource"></a>Building IronPython from Source</h2>
  154. <p>
  155. If you downloaded the binaries from
  156. <a href="http://www.codeplex.com/ironpython">www.codeplex.com/ironpython</a><span style="color: #000000">,
  157. you do not need to build it.&nbsp; </span>To compile IronPython from the source code, you can install either Visual
  158. Studio 2010 or .NET Framework 4.0 using one
  159. of the following
  160. links:</p>
  161. <ul>
  162. <li>
  163. <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9cfb2d51-5ff4-4491-b0e5-b386f32c0992&amp;displaylang=en">Microsoft .NET Framework Version
  164. 4.0</a></li><li>
  165. <a href="http://www.microsoft.com/visualstudio/en-us/howtobuy/default.mspx">Visual Studio 2010
  166. </a> </li>
  167. </ul>
  168. <h3>
  169. Building using Visual Studio 2010</h3>
  170. <p>
  171. Open IronPython.sln in Visual Studio 2010 and build (from menu: Build-&gt;Build Solution).&nbsp; Set IronPythonConsole as your startup project
  172. in the Solution Explorer.</p>
  173. <h3>
  174. Building using .NET Framework 4.0</h3>
  175. <p>
  176. .NET Framework 4.0 comes with the C# compiler and Microsoft's msbuild.&nbsp; After installing
  177. .NET, open any command prompt,
  178. cd to the IronPython directory, and execute:</p>
  179. <blockquote>
  180. <pre>%SystemDrive%\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild Solutions\IronPython.sln</pre>
  181. </blockquote>
  182. <p>This will build all required Dynamic Language Runtime and IronPython
  183. assemblies which include but are not limited to: IronPython.dll, IronPython.Modules.dll, Microsoft.Scripting.dll,
  184. Microsoft.Dynamic.dll, Microsoft.Scripting.Debugging.dll, ipy.exe, and ipyw.exe.</p>
  185. </body>
  186. </html>