Building PyXPCOM

  • Revision slug: Building_PyXPCOM
  • Revision title: Building PyXPCOM
  • Revision id: 121876
  • Created:
  • Creator: Alex Tarkovsky
  • Is current revision? No
  • Comment Cleanup; shared Python is already built by all but the oldest Python ebuilds in Portage

Revision Content

Compiling Python

PyXPCOM requires access to a shared Python library. If you have libpython2.*.so.* in /usr/lib or /usr/local/lib, you can skip to the Compiling Mozilla section. Otherwise you'll need to recompile Python with the --enable-shared configure flag to build the shared library.

Gentoo systems

If your Python ebuild is later than python-2.2.3-r6 then the shared library was already built by default and you can skip to Compiling Mozilla. If you're using python-2.2.3-r6 or earlier, perform the following steps to modify the ebuild and re-emerge Python.

First, copy the official ebuild to your Portage overlay and modify it like so:

cp /usr/portage/dev-lang/python/python-2.2.3-r6.ebuild /usr/local/portage/dev-lang/python/python-2.2.3-r7.ebuild
cp /usr/portage/dev-lang/python/files/python-2.2* /usr/local/portage/dev-lang/python/files/
nano /usr/local/portage/dev-lang/python/python-2.2.3-r7.ebuild

Find the following line in the function src_compile():

local myopts

Below it add the line:

myopts = "${myopts} --enable-shared "

Hit CRTL-O then CTRL-X to save the file and exit nano.

Make sure Portage knows where your overlay is. If you don't have a line similar to the following in your /etc/make.conf then add it:

PORTDIR_OVERLAY="/usr/local/portage"

Finally, build the manifest for the modified ebuild then emerge it:

ebuild /usr/local/portage/dev-lang/python/python-2.2.3-r7.ebuild digest
emerge =python-2.2.3-r7

Other systems

If you don't have Gentoo, get the Python source from python.org and do:

tar zxf Python2.4.tar.bz2    # Or whatever the filename is; latest stable is probably best
cd python
./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:

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
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

Hit Ctrl+D, then:

make -f client.mk build


Testing

To test your PyXPCOM build:

cd suite-debug/dist/bin
export PYTHONPATH=python
./run-mozilla.sh ./seamonkey -chrome chrome://pyxultest/content

Revision Source

<h3 name="Compiling_Python"> Compiling Python </h3>
<p>PyXPCOM requires access to a shared Python library. If you have <code>libpython2.*.so.*</code> in <code>/usr/lib</code> or <code>/usr/local/lib</code>, you can skip to the <a href="en/Building_PyXPCOM#Compiling_Mozilla">Compiling Mozilla</a> section. Otherwise you'll need to recompile Python with the <code>--enable-shared</code> configure flag to build the shared library.
</p>
<h4 name="Gentoo_systems"> Gentoo systems </h4>
<p>If your Python ebuild is <i>later than</i> <code>python-2.2.3-r6</code> then the shared library was already built by default and you can skip to <a href="en/Building_PyXPCOM#Compiling_Mozilla">Compiling Mozilla</a>. If you're using <code>python-2.2.3-r6</code> or earlier, perform the following steps to modify the ebuild and re-emerge Python.
</p><p>First, copy the official ebuild to your Portage overlay and modify it like so:
</p>
<pre>cp /usr/portage/dev-lang/python/python-2.2.3-r6.ebuild /usr/local/portage/dev-lang/python/python-2.2.3-r7.ebuild
cp /usr/portage/dev-lang/python/files/python-2.2* /usr/local/portage/dev-lang/python/files/
nano /usr/local/portage/dev-lang/python/python-2.2.3-r7.ebuild
</pre>
<p>Find the following line in the function <code>src_compile()</code>:
</p>
<pre>local myopts
</pre>
<p>Below it add the line:
</p>
<pre>myopts = "${myopts} --enable-shared "
</pre>
<p>Hit <i>CRTL-O</i> then <i>CTRL-X</i> to save the file and exit nano.
</p><p>Make sure Portage knows where your overlay is. If you don't have a line similar to the following in your <code>/etc/make.conf</code> then add it:
</p>
<pre>PORTDIR_OVERLAY="/usr/local/portage"
</pre>
<p>Finally, build the manifest for the modified ebuild then emerge it:
</p>
<pre>ebuild /usr/local/portage/dev-lang/python/python-2.2.3-r7.ebuild digest
emerge =python-2.2.3-r7
</pre>
<h4 name="Other_systems"> Other systems </h4>
<p>If you <i>don't</i> have Gentoo, get the Python source from <a class="external" href="http://www.python.org">python.org</a> and do:
</p>
<pre>tar zxf Python2.4.tar.bz2    # Or whatever the filename is; latest stable is probably best
cd python
./configure --enable-shared --prefix=/usr    # Adjust prefix to install over your current Python
make
sudo make install
</pre>
<p><br>
</p>
<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:
</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
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
</pre>
<p>Hit <i>Ctrl+D</i>, then:
</p>
<pre>make -f client.mk build
</pre>
<p><br>
</p>
<h3 name="Testing"> Testing </h3>
<p>To test your PyXPCOM build:
</p>
<pre>cd suite-debug/dist/bin
export PYTHONPATH=python
./run-mozilla.sh ./seamonkey -chrome chrome://pyxultest/content
</pre>
Revert to this revision