wiki:pyxpcom

PYXPCOM

Python Cross Platform Component Object Model

This technology will replace our local web server in release 0.6 and beyond.

Benefits

  • PyXPCOM will make increase the products stability a great deal, getting rid of connection loss problems with HTTP and nevow.
  • It will enable us to replace most of the javascript code with more structured python objects.
  • It will get rid of mozilla security problems using xpcom components (which we are currently doing from javascript).
  • It will mean that we don't need to reduce the security to nothing in the mozilla profile and turn off security at the top of every javascript function
  • There will be no need to make our own firefox profile directory on installation
  • The user will be able to open other web browsers and instances of firefox while running exe
  • We will be able to have a "quit" option in the file menu

Developer Info

Here's how to get pyxpcom working on you machine.

Summary

  1. Install distcc
  2. Download older version of autoconf (autoconf213-2.13-9.noarch.rpm)
  3. Download mozilla source code
  4. Download patch and apply patch - https://bugzilla.mozilla.org/attachment.cgi?id=186062
  5. create attachment:.mozconfig file
  6. Download and build Python2.4.1
    • ./configure --prefix=/usr --debug --enable-unicode=ucs2
  7. compile everything

distcc

DistCC helps us compile things much faster by using everyone elses cpu. However when building mozilla, the build breaks more, so probably best not to use it.

compiling

If you want to use distcc: export PATH=/usr/lib/distcc/bin:$PATH # Put distcc bin first

  1. cd to mozilla dir
  2. autoconf-2.13
  3. ./configure
  4. make # (make -j24 if using distcc)
  5. (Make coffee, go home, sleep, come back if not using distcc)
  6. (If something doesn't build, just cd to that dir, and type make in it, then go back to the mozilla source dir and type 'make' again and carry on)

installing

  1. from the mozilla source dir
  2. sudo make install

Calling XPCOM from Python

Once you've compiled and installed everything

  1. ln -s /home/djm/work/firefox/mozilla/extensions/python/xpcom/src/lib_xpcom.so _xpcom.so
  2. (If developing, its nice to run with your work dir)
    1. rm -rf /usr/lib/MozillaFirefoxOptimized/lib/firefox-1.0.4/python
    2. ln -s /home/djm/work/firefox/mozilla/extensions/python /usr/lib/MozillaFirefoxOptimized/lib/firefox-1.0.4/python
  3. export LD_LIBRARY_PATH="/usr/lib/MozillaFirefoxOptimized/lib/firefox-1.0.4"
  4. export PYTHONPATH=/usr/lib/MozillaFirefoxOptimized/lib/firefox-1.0.4/python
  5. export MOZILLA_FIVE_HOME=/usr/lib/MozillaFirefoxOptimized/lib/firefox-1.0.4 (or whereever your .so files live)
  6. /usr/local/lib/python

{{{import xpcom from xpcom import components f=components.classes@mozilla.org/supports-float;1.createInstance(components.interfaces.nsISupportsFloat) f.data=3.1415926 print f.toString()}}}

Links to PyXPCOM Resouces

Last modified 10 years ago Last modified on 2009-05-22T06:14:14+09:00

Attachments (2)

Download all attachments as: .zip