mozilla

Revision 121877 of Building PyXPCOM

  • Revision slug: Building_PyXPCOM
  • Revision title: Building PyXPCOM
  • Revision id: 121877
  • Created:
  • Creator: Alex Tarkovsky
  • Is current revision? No
  • Comment added clarifications based on further investigation

Revision Content

Compiling 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/python2.*/config, you meet the shared library requirement and can skip to the Compiling Mozilla section. If you have that file but it's located in /usr/lib (or whatever your system's library path is) instead, then create the proper symlink as instructed below in Building PyXPCOM#Python 2.3 and later. If you don't have that file at all then you'll need to recompile Python with --enable-shared as outlined in this section.

Gentoo systems

Python 2.3 and later

If your installed Python ebuild is python-2.3* or later then the shared library was already built by default. However, as of this writing even the latest Python ebuilds fail to properly symlink the shared library, so if for instance you're using python-2.4.2 then you'll need to create the symlink manually:

ln -s /usr/lib/libpython2.4.so /usr/lib/python2.4/config/libpython2.4.so

Continue with Building PyXPCOM#Compiling Mozilla.

Python 2.2 and earlier

If you're using python-2.2* 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 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
make -f client.mk build


Testing

To test your newly-built PyXPCOM:

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. 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/python2.*/config</code>, you meet the shared library requirement and can skip to the <a href="en/Building_PyXPCOM#Compiling_Mozilla">Compiling Mozilla</a> section. If you have that file but it's located in <code>/usr/lib</code> (or whatever your system's library path is) instead, then create the proper symlink as instructed below in <a href="en/Building_PyXPCOM#Python_2.3_and_later">Building PyXPCOM#Python 2.3 and later</a>. If you don't have that file at all then you'll need to recompile Python with <code>--enable-shared</code> as outlined in this section.
</p>
<h4 name="Gentoo_systems"> Gentoo systems </h4>
<h5 name="Python_2.3_and_later"> Python 2.3 and later </h5>
<p>If your installed Python ebuild is <code>python-2.3*</code> or later then the shared library was already built by default. However, as of this writing even the latest Python ebuilds fail to properly symlink the shared library, so if for instance you're using <code>python-2.4.2</code> then you'll need to create the symlink manually:
</p>
<pre>ln -s /usr/lib/libpython2.4.so /usr/lib/python2.4/config/libpython2.4.so
</pre>
<p>Continue with <a href="en/Building_PyXPCOM#Compiling_Mozilla">Building PyXPCOM#Compiling Mozilla</a>.
</p>
<h5 name="Python_2.2_and_earlier"> Python 2.2 and earlier </h5>
<p>If you're using <code>python-2.2*</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> 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>
<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 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
make -f client.mk build
</pre>
<p><br>
</p>
<h3 name="Testing"> Testing </h3>
<p>To test your newly-built PyXPCOM:
</p>
<pre>cd suite-debug/dist/bin
export PYTHONPATH=python
./run-mozilla.sh ./seamonkey -chrome chrome://pyxultest/content
</pre>
Revert to this revision