Subject: Python binaries for mozilla

This is a multi-part message in MIME format.
I've been thinking about and playing with ways to create a Python XPI for
Mozilla. As I've mentioned before, this XPI needs to bundle Python itself
along with the 'pyxpcom' and new 'nsdom' packages. We don't want to rely on
a pre-installed Python (that places too much burden on the end user and too
much scope for error), but at the same time we want to co-exist with any
installed Pythons.

Here are my thoughts - I welcome all feedback, particularly from the
ActiveState guys who already have some experience in this area. For the
sake of this discussion, let's assume Python 2.4 (although I'm leaning
towards jumping straight to 2.5 once officially released.) Also, let's
assume Windows (other OS' will be very similar)

The XPI installs:

* python24.dll into the moz 'bin' directory. On Windows, we patch the
resource string that is used for 'winver' - hence the normal Python24
registry keys will be totally ignored.

* into the 'bin' directory. This is just the standard Python
library compiled as .pyo files. The source files to the stdlib are not
shipped. A 'manifest' in the build script defines exactly what is included
(eg, test suite and all 'plat-*' dirs are removed). This is created with no
compression (so should be *faster* than including the lib on disk)

* A 'bin/python24' directory is created. This has a single subdir 'DLLs'
with the standard Python .pyd files. The intent is that this directory be
laid out like a standard Python install (but minus the 'lib' dir if the zip
file is included - which it currently is). The intent is that code like
distutils, which sniffs out various important Python directories should
still work if executed in this environment.

* A 'bin/python' directory - this is the Mozilla related Python library as
currently created by the Mozilla build process (assuming Python extensions
are included ) - ie, the 'xpcom' and 'nsdom' packages. Although much of
this could also go into a .zip file, I figured that initially we just ship
with these .py files on disk to help people who want to read/debug the
source (which they really have no need to do with the stdlib itself)

* 3 components are shipped - the pyxpcom loader, the nsdom component, and This means that once installed, about the only thing you can do
is type "about:python" into the browser bar. No examples or samples are
shipped - they can come in their own .xpi file.


* On non-windows platforms, will there be a need to "patch" our .so files to
remove the reference to /usr/local, or whatever was used when pyxpcom was
actually build? I seem to recall Shane mentioning something about that.
Any other non-windows issues I remain oblivious to?

* By default, the PYTHONPATH is not correct - specifically 'python24/DLLs'
etc are not on it. If you set PYTHONHOME manually to
"c:\path\to\mozilla\bin\python24", it works correctly. I think the pyxpcom
loader should be modified to check if 'bin/python24' exists, and set
PYTHONHOME accordingly. The directory will not exist for people who build
moz and python from source, so should continue to work as now. Thoughts or

* Firefox needs to be restarted after installation so the new components are
registered. I haven't worked out how to do that.

I've attached my hacky script that does this, and it actually creates a .xpi
on windows that works! about:python works fine (but shows a 'bad'
sys.path - as above, manually setting PYTHONHOME before starting firefox
makes it good)

I welcome all comments (including a better name for the script ;)



Description: Binary data

Programming list archiving by: Enterprise Git Hosting