mozilla

Revision 121884 of Building PyXPCOM

  • Revision slug: Building_PyXPCOM
  • Revision title: Building PyXPCOM
  • Revision id: 121884
  • Created:
  • Creator: Alex Tarkovsky
  • Is current revision? No
  • Comment Removing extra Gentoo steps: latest CVS seems to fix issues with Gentoo

Revision Content

Installing Python

PyXPCOM requires access to a shared Python library. The official Python installer for Windows installs this library automatically, so Windows users can simply install Python and skip to Compiling Mozilla.

For non-Windows users, if you already have Python installed and you have the file libpython2.*.so* in /usr/lib, you meet the shared library requirement and can skip to Compiling Mozilla. If you don't have that file then you'll need to compile Python with --enable-shared as outlined in this section.

Gentoo systems

A shared Python library seems to only be possible with python-2.3* or later, so you'll need to upgrade if you're using python-2.2* or earlier. For ebuilds python-2.3* and later the shared library is built and installed by default.

Other systems

If you don't use Windows or Gentoo, get the latest stable Python source tarball from python.org and do:

tar xjf Python-2.4.2.tar.bz2
cd Python-2.4.2
./configure --enable-shared --prefix=/usr  # Adjust --prefix to install over your current Python
make
sudo make install

Compiling Mozilla

Check out Mozilla from DOM_AGNOSTIC2_BRANCH in CVS and build it:

cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r DOM_AGNOSTIC2_BRANCH mozilla/client.mk
cd mozilla
make -f client.mk checkout MOZ_CO_PROJECT=suite
cat > .mozconfig << "EOF"
mk_add_options MOZ_CO_PROJECT=suite
ac_add_options --enable-application=suite
ac_add_options --enable-default-toolkit=gtk2
ac_add_options --enable-xft
ac_add_options --enable-extensions=python/xpcom,python/dom,default
ac_add_options --disable-optimize
ac_add_options --enable-debug
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/suite-debug
EOF
autoconf
make -f client.mk build

Testing PyXPCOM

To test your fresh PyXPCOM build from within Mozilla's runtime environment:

cd suite-debug/dist/bin
export PYTHONPATH=$PYTHONPATH:$HOME/mozilla/suite-debug/dist/bin/python # Adjust this to your PyXPCOM build path
./run-mozilla.sh ./seamonkey -chrome chrome://pyxultest/content

In the same directory, perform this simple test of the Python XPCOM module from a standalone Python environment:

python -c 'from xpcom import components; print components.classes["@mozilla.org/file/local;1"]'

If this standalone test fails, make sure $PYTHONPATH is still set the same as in the first test.

Revision Source

<h3 name="Installing_Python"> Installing Python </h3>
<p>PyXPCOM requires access to a shared Python library. The official Python installer for Windows installs this library automatically, so Windows users can simply install Python and skip to <a href="en/Building_PyXPCOM#Compiling_Mozilla">Compiling Mozilla</a>.
</p><p>For non-Windows users, if you already have Python installed and you have the file <code>libpython2.*.so*</code> in <code>/usr/lib</code>, you meet the shared library requirement and can skip to <a href="en/Building_PyXPCOM#Compiling_Mozilla">Compiling Mozilla</a>. If you don't have that file then you'll need to compile Python with <code>--enable-shared</code> as outlined in this section.
</p>
<h4 name="Gentoo_systems"> Gentoo systems </h4>
<p>A shared Python library seems to only be possible with <code>python-2.3*</code> or later, so you'll need to upgrade if you're using <code>python-2.2*</code> or earlier. For ebuilds <code>python-2.3*</code> and later the shared library is built and installed by default.
</p>
<h4 name="Other_systems"> Other systems </h4>
<p>If you <i>don't</i> use Windows or Gentoo, get the latest stable Python source tarball from <a class="external" href="http://python.org/download/">python.org</a> and do:
</p>
<pre>tar xjf Python-2.4.2.tar.bz2
cd Python-2.4.2
./configure --enable-shared --prefix=/usr  # Adjust --prefix to install over your current Python
make
sudo make install
</pre>
<h3 name="Compiling_Mozilla"> Compiling Mozilla </h3>
<p>Check out Mozilla from <a class="external" href="http://wiki.mozilla.org/Breaking_the_grip_JS_has_on_the_DOM">DOM_AGNOSTIC2_BRANCH</a> in CVS and build it:
</p>
<pre>cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r DOM_AGNOSTIC2_BRANCH mozilla/client.mk
cd mozilla
make -f client.mk checkout MOZ_CO_PROJECT=suite
cat &gt; .mozconfig &lt;&lt; "EOF"
mk_add_options MOZ_CO_PROJECT=suite
ac_add_options --enable-application=suite
ac_add_options --enable-default-toolkit=gtk2
ac_add_options --enable-xft
ac_add_options --enable-extensions=python/xpcom,python/dom,default
ac_add_options --disable-optimize
ac_add_options --enable-debug
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/suite-debug
EOF
autoconf
make -f client.mk build
</pre>
<h3 name="Testing_PyXPCOM"> Testing PyXPCOM </h3>
<p>To test your fresh PyXPCOM build from within Mozilla's runtime environment:
</p>
<pre>cd suite-debug/dist/bin
export PYTHONPATH=$PYTHONPATH:$HOME/mozilla/suite-debug/dist/bin/python # Adjust this to your PyXPCOM build path
./run-mozilla.sh ./seamonkey -chrome chrome://pyxultest/content
</pre>
<p>In the same directory, perform this simple test of the Python XPCOM module from a standalone Python environment:
</p>
<pre>python -c 'from xpcom import components; print components.classes["@mozilla.org/file/local;1"]'
</pre>
<p>If this standalone test fails, make sure <code>$PYTHONPATH</code> is still set the same as in the first test.
</p>
Revert to this revision