WiiPy

From WiiBrew
Jump to navigation Jump to search
WiiPy
General
Author(s)tehpola, comex
TypePorted Libraries
Links
Download
Website

Pronounced "weepy".

PyOGC is a Libogc wrapper for the scripting Language Python written in Pyrex (a hybrid Python-C language designed for extension development). The author, tehpola, made a working demo, but the demo itself was made in Pyrex, not real Python. I (comex) hacked Python a little so the interpreter as well would run, and you can run .py files.

Aside from Python being an awesome language, I think Python on Wii might eventually make it much easier for GUI applications to be developed on the Wii, or really anything.

Right now, however, it does not have any GUI, and PyOGC itself is incomplete-- this is really just a demo. The finished version might have have a file selector and maybe a GUI and all that fancy stuff.

Usage

To use, download wiipy.elf, run it by the method of your choice, and put a file called "run.py" on your SD card root containing whatever Python code you want to run.

Besides the modules in PyOGC (the documentation for this is nonexistent, but you can look in the source) you have some basic modules (math, sys), and the standard open() function will open files on the SD card. However, notably, time is presently not available, nor is os and maybe other things.

Alpha 2: Network is available, do this:

import net, _socket as socket
net.init()

Then use the socket functions, but there are some bugs:

  • socket.accept won't actually tell you the IP address which connected
  • You must receive and send data in small chunks. 1024 works, 8192 doesn't (you get a socket error). This is a limitation of the net functions, but future version will deal with this more smartly (chunk data up for you).

Sample

Here is a link of a .py port of the original sample file: [1]

Bugs

  • For some reason, this app seems to fail in weird and wacky ways when launched over the network from HBC. I've only gotten it to work when launched from the SD card. I haven't tested with any additional loaders or the Twilight Hack. YMMV.
  • If the script crashes, you will not get a delay before an immediate return to the loader. This is because traceback (which would be required to print the stack trace without exiting python) wants to import os for some reason. This is fixable.
  • For some reason importing os results in a "ImportError: Excluded frozen object named errno"

Source

comex gave me its patches to PyOGC and python-2.5.2 I made a google code project, and some simple scripts to somehow automate the build process. http://code.google.com/p/wiipy/source/checkout --Tardyp 14:47, 2 August 2008 (CEST)