[HOME]
| LastModified: | Sun Mar 23 13:31:02 JST 2008 |
|---|
IronPython 1.1.1 can run under Mac OS X Panther(10.3) with Mono 1.2.9_5 Framework - Universal. If you install Mono (via MonoFramework-1.9_5.macos10.novell.universal.dmg), you are ready to use IronPython. Note that current Mono version does not support Panther as a platform, but the 1.2.9_5 still works fine on my Panther.
The ipy command included in the Mono distribution:
$ type ipy ipy is hashed (/usr/bin/ipy) $ cat /usr/bin/ipy #!/bin/sh exec /Library/Frameworks/Mono.framework/Versions/1.9/bin/mono /Library/Frameworks/Mono.framework/Versions/1.9/lib/IPCE/ipy/ipy.exe "$@" $ ipy IronPython 1.1 (1.1) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>>
However, as seen above, the module ipy.exe is the version 1.1, which is older. We can upgrage IronPython to 1.1.1 by downloading the source from IronPython - Home . Building IronPython 1.1.1 can by done only by changing from CSC=csc to CSC=gmcs of makefile in Src.
The delete key on MAC OS X does not work in IronPython interactive session. Use control+H instead.
To quit IronPython session, we do import sys and then do sys.exit().
$ uname -a
Darwin hagi.local 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC Power Macintosh powerpc
$ pwd
/Users/zgzg/IronPython-1.1.1
$ ls
Doc/ IronPython.dll* License.html Src/ ipyw.exe*
FAQ.html Lib/ Mapack.dll* Tutorial/
IronMath.dll* License.Rtf Readme.html ipy.exe*
$ mono --version
Mono JIT compiler version 1.9 (tarball)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
TLS: normal
GC: Included Boehm (with typed GC)
SIGSEGV: normal
Notification: Thread + polling
Architecture: ppc
Disabled: none
$ mono ipy.exe
IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import sys
>>> sys.path
['/Users/zgzg/IronPython-1.1.1', '/Users/zgzg/IronPython-1.1.1/Lib']
>>> sys.path.append('/Users/zgzg/IronPython-1.1.1/Tutorial')
>>> import first
>>> first.factorial(19)
121645100408832000L
>>> import clr
>>> clr.AddReferenceToFile("Mapack.dll")
>>> from Mapack import *
>>> m = Matrix(2,2,1.2)
>>> N = Matrix(2,1)
>>> N[0,0]=4
>>> print m*N
4.8
0
>>> print N.Transpose()*m
4.8 0
>>> print m*3
3.6 0
0 3.6
>>> print N + -N
0
0
>>> sys.platform
'cli'
>>> import System
>>> System.Environment.OSVersion.ToString()
'Unix 7.9.0.0'
>>> System.Environment.OSVersion.Platform.ToString()
'Unix'
>>> System.Environment.GetCommandLineArgs()[0]
'/Users/zgzg/IronPython-1.1.1/ipy.exe'
>>> vars = System.Environment.GetEnvironmentVariables()
>>> for var in vars:
... print var.Key,":",var.Value
...
MANPATH : /usr/share/man:/usr/local/man:/usr/local/share/man:/usr/X11R6/man:/Users/zgzg/man
(snip)
>>> System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion()
'V2.0.50727'
>>> System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
'/Library/Frameworks/Mono.framework/Versions/1.2.6/lib/mono/2.0'
>>> System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFile
'/Library/Frameworks/Mono.framework/Versions/1.2.6/etc/mono/2.0/machine.config'
>>> System.DateTime.Now.ToString()
'02/03/2008 15:44:45'
>>> System.IO.File.Exists("tmpfile.html")
False
>>> System.IO.File.Exists("ipy.exe")
True
>>> System.IO.Path.GetTempPath()
'/var/tmp/'
>>> System.IO.Path.GetTempFileName()
'/var/tmp/tmp6480994e.tmp'
>>> System.Net.Dns.GetHostName()
'hagi.local'
>>> wc = System.Net.WebClient()
>>> wc.DownloadFile("http://textdirected.googlepages.com","tmpfile.html")
>>> System.IO.File.Exists("tmpfile.html")
True
>>> ipinfo = System.Net.Dns.GetHostEntry("textdirected.googlepages.com")
>>> ipinfo.HostName
'Googlepages.l.google.com'
>>> for i in ipinfo.AddressList:
... print i
...
64.233.xxx.yy
64.233.xxx.zz
64.233.xxx.tt
>>> p = System.Diagnostics.Process.Start('ls')
Doc IronPython.dll Mapack.dll Src ipyw.exe
FAQ.html Lib Readme.html Tutorial
IronMath.dll License.html Samples ipy.exe
Winforms can be run under X11 xterm provied by Apple Computer. An example is winforms_hw.py found in IronPython-1.0-Samples-Pyc.zip .

Main program:
$ cat PyCallPyDLL_main.py
import clr
clr.AddReferenceToFile("PyCallPyDLL_sub.dll")
import PyCallPyDLL_sub
PyCallPyDLL_sub.sub()
Sub program:
$ cat PyCallPyDLL_sub.py
def sub():
print "Hello."
Build dll:
$ mono ipy.exe Pyc.py /target:dll PyCallPyDLL_sub.py
Input Files:
PyCallPyDLL_sub.py
Resource Files:
Output:
PyCallPyDLL_sub.dll
Target:
Dll
Build exe:
$ mono ipy.exe Pyc.py /target:exe /reference:PyCallPyDLL_sub.dll PyCallPyDLL_main.py
Input Files:
PyCallPyDLL_main.py
Resource Files:
Output:
PyCallPyDLL_main.exe
Target:
ConsoleApplication
Run it:
$ mono PyCallPyDLL_main.exe Hello.