Dec 13, 2007

Jhbuild and Windows - We Meet Again

The Good News

Following on from my last post I have continued work on getting Jhbuild to run on windows (within msys). The basic problem which I identified in my last post was the struggle between Python (for Windows) expectations about paths, and the hoops that msys and cygwin jump through to allow unix style paths to be used. Basically os.path.join and friends do the correct thing providing the subsequent path is used within python alone. Things get all difficult when that path is then passed out to a configure script, or as an argument to a shell command. With that in mind however, a picture speaks a thousand words....

JHBuild on Windows

  1. It works...

  2. On windows...

  3. Through magic....

The Status

Jhbuild is successfully able to build a test moduleset, and even some real modules such as zlib and iconv on windows using the mingw compiler. Things are looking promising and I will continue to play with this tomorrow. Its a bit of a pain to debug because of the inconsistancies between how subprocess.Popen behaves on windows and on linux. So far my changes can be summarised as follows

  1. Add Makefile.win32 and patch install-check to just call /usr/bin/install

  2. Replace wget/curl with pythons built in urllib.urlretrieve

  3. Replace tar/unzip with pythons built in tarfile and zipfile modules

  4. Misc fixes to get Jhbuild to start including disabling the tray icon etc

  5. Refactor buildscript.execute (the subprocess.Popen) wrapper to clean it up and to special case local script commands from system commands (because of differences in how win32 treats executing executables in the current dir). Best summarised as the following

    def execute_script(self, command, args_str='', cwd=None, extra_env=None): # THIS IS THE MAIN WIN32 HACK if sys.platform.startswith('win') and command[0].startswith('./'): command = ['sh', command[0].replace('./','')] + command[1:]

Jhbuild still works on Linux just as it used to (more or less, I need to port over some more things to the new buildscript.execute() functions). Wget/tar/curl/unzip etc are still used on Linux. In general the changes so far have been self contained and should not break regular operation

The Install Procedure

How can you try this pre-alpha code out?. Follow these steps on windows and check out from my bzr branch (or use the patch against SVN)

  1. Install MinGW combined installer (MinGW-5.1.3) to C:\mingw

  2. Install msysCORE-1.0.11-2007.01.11 to C:\msys

  3. Run C:\msys\postinstall\pi.bat, answer yes when it asks whether mingw is already installed and point it to C:/mingw. Launching C:\msys\msys.bat now provides us with a minimal unix-like shell.

  4. Install Python 2.5.1 to default location (C:\Python25)

  5. Install bzr for windows to the (C:\Bazaar)

  6. Start msys.bat (in C:\msys)

  7. Install Jhbuild

    1. bzr co http://www.gnome.org/~jstowers/bzr/jhbuild-win32 jhbuild-win32

    2. cd jhbuild-win32

    3. make -f Makefile.win32 install

  8. Add python to path. Other path manipulation is done within JHBuild. Add the following line to ~/.profile

    export PATH=$PATH:/c/Python25:/c/Python25/bin

You should now have a minimal msys install with JHBUILD. Test by performing

  • cd ~/bin

  • python jhbuild --help

Finally, you can now install the test modules with

python jhbuild -f jhbuild-win32/test.jhbuildrc build test

Standard disclaimers apply, alpha quality code, help appreciated, yada yada yada. Now back to Conduit hacking....