The best kittens, technology, and video games blog in the world.

Monday, May 28, 2007

How py2exe made me stop coding jrpg

Rainbow Boa by bsmith4815 from flickr (CC-NC-SA)
That's a simple story but it illustrates something important. jrpg is an SNES RPG style game which helps the player learn Japanese writing system. It is written in Python with PyGame. Well, data preprocessing is done mostly in Perl, and the build system is in Ruby rake, but the game code is pure Python. Unfortunately that means users needed Python and PyGame installed to play jrpg. No problem for Linuxers, but Windows users were really confused by that.

Then I found py2exe - an awesome tool which turned Python programs into standalone Windows executables. Thanks to py2exe and some "marketing" jrpg downloads went into thousands. There was only one problem - py2exe doesn't run on Linux.

That turned rake package; rake update_website into a long and painful task. If I changed anything in jrpg, I had to copy jrpg package onto a pendrive, go to some Windows box (hopefully with Python, PyGame, and py2exe already installed), build the Windows package, copy it back to the pendrive, go back to the Linux box, put it in the right directory, and only then I could upload the package. Knowing that I have to go to such lengths every time I change one line of code in jrpg completely killed the joy of coding.

What could I do ? I couldn't make myself stop updating the Windows package and loss 80% of the users. I tried running py2exe under wine and Cedega (it failed), porting it to Linux (unfortunately py2exe uses too many Windows-specific APIs I don't have a slightiest idea about, and low-level C coding is not a fun thing to do), even hacking the produced exe file. Nothing worked.

I guess I might get back to coding jrpg. Maybe someone will hack a crosscompiler onto py2exe, maybe someone will create easily installable dosbox-alike with Windows on which I'll be able to run py2exe, maybe my desire to hack it will temporarily overcome my disgust.

The moral of the story - hacking must be fun, or people will go hack something else.

11 comments:

darrint said...

If you put cygwin and an ssh server on the windows box you can invoke the command remotely.

Try ssh [remote-host] ls

Between ssh, cygwin, and the cygpath -w command, you might find a little light at the end of your tunnel.

Marijn said...

Or use vmware to run a Windows inside your normal OS. Testing my JavaScript programs in Internet Explorer was always extremely painful, but with a 'virtual windows' running alongside my normal development tools it is a breeze.

Peter Cooper said...

Why not take the Skype attitude, and just do all your main development on one platform, keep the trunk going on Linux, then just do Windows builds at the minor version levels?

taw said...

Darrint: I don't have an always-running Windows box on a local network, I'm using some ancient box to do the packaging. But you're right - it's possible to make it somewhat less painful than it currently is.

Marijn: How much time does it take to setup VMWare, install Windows on it, and make it possible to upload files there and run commands ?

Peter Cooper: I think I would feel horrible leaving something uncomplete like that, with Linux version being new and Windows version having known bugs or missing some cool new feature.

divide said...

Taw: I think VMWare is the way to go. I bet you can torrent premade images of Windows -- from there it's just a matter of installing cygwin in the VM environment and off you go.

Marijn: You do realise that IE does run on Wine, and, in fact, does it pretty well? There is even an automated installer. Just google for ies4linux.

Zverok said...

There is a simple solution: not to pack all into one file, but create windows-related package, including python and pygame, and run.bat with command like "python.exe jrpg.py".

Slightly more complex solution I've made once for Ruby is custom Windows-compiled Ruby interpreter, which is renamed to my_app.exe and instead of looking for command line args, looks for my_app.rb and interprets it.

Both of those solutions allow to make Windows package on Linux machine - nothing to be compiled, new sources just packed with all interpreter.

vilma said...

try this:
http://starship.python.net/crew/atuining/cx_Freeze/

Kornel said...

VMWare IS the way to go. Since I installed VMWare, I can do linux versions of my games without *any* problems :).

taw said...

Kornel: Well, Linux is far easier to install than Windows. You can simply unpack an image or burn a Knoppix. I'm affraid setting Windows on vmware up may take a few days.

grubert said...

installing python24, py2exe under wine workes almost. the generated exe does not start on winxp, but it works with the executable from a previous build on windows. so i build under wine and keep the executable.

taw said...

grubert: That was the first thing I tried, but it simply crashed due to something in Wine being unimplemented. In any case VirtualBox works quite well.