|
| <prev next> |
Re: Python binaries for mozilla: msg#00015mozilla.devel.xpcom.python
This is a multi-part message in MIME format. Mark Hammond wrote: I've been thinking about and playing with ways to create a Python XPI for Okay, you motivated me to start writing up what Komodo does for its embedded/siloed Python. I'll include my notes and then respond to some of your points below that: [Trent's Komodo-Python notes] Embedding Notes [Back to Mark's notes] The XPI installs: Yup. Similarly for Linux/Unix. Not necessary for Mac OS X. On Windows we also place the PyWin32 sysdir DLLs there. > On Windows, we patch the resource string that is used for 'winver' - hence the normal Python24 I have a patch to the Python source that I apply pre-build to instead disable Windows registry lookup for sys.path. I think that is better solution for the more generic "building Python for embedding" problem. I've attached the patch (which includes some notes at the top). Thoughts? Yours is obviously a little simpler because it can be done post-Python-build.
Currently Komodo is just including the Python stdlib '.py' files over in the equivalent of the 'bin/python24' directory that you mention in your next point. Zipping up the stdlib sounds like a good idea. See my comments on your next point.
Komodo's embedded Python isn't as tightly integrated into the $mozBin directory as you are describing here. Generally the layout is like this: $komodoInstallDir/ lib/ mozilla/... # the mozilla build is here python/... # ** ** All the Python bits are here except the main DLLs in $mozBin. This dir basically looks like a std, but trimmed down, Python install. On Mac OS X the "Frameworks" system allows for the pretty much typical Python install image to be placed in: $komodoInstallDir/Contents/Frameworks/Python.framework/... As you mention, one of Komodo's goals for the embedded Python is that it can be run as a normal Python install (for building extensions and for development-debugging). Does your moving the stdlib to 'python24.zip' in the $mozBin directory break that? I.e. will distutils work the way you've described it. Also, will just including the .pyo files in the stdlib zip cause problems/confusion trying to run distutils there (people typically won't run with "python -O"/PYTHONOPTIMIZED).
Right. This is what Komodo is currently doing (no 'nsdom' in Komodo yet, of course): $mozBin/ python/ xpcom/ Note that we also place Python modules and packages used by Komodo-specific PyXPCOM components under there: $mozBin/python/ komodo.pth # add 'komodo' dir to sys.path komodo/... # our Python libs here A general best-practices along these lines (or something more appropriate) for xulrunner-based apps might be in order at some point. * 3 components are shipped - the pyxpcom loader, the nsdom component, and Sounds good. Issues: This is mentioned in my notes at the top. Windows: nothing required. Mac OS X: easy steps that can be done before packaging the XPI. Linux/Unix: PITA steps that have to be done post-install. Can this stuff be done with the XPI system? Some gotchas: 1. Relocating from Python's build PREFIX to whereever the Mozilla-based app is installed requires that the PREFIX has more characters than the actual install dir. Hence you need a Python build with a intentionally long and bogus PREFIX. (My suspicion is that there may be some complicated source/built work that could be done to Python to get around this requirement. I don't know that though.) 2. I still haven't really dealt with the libstdc++ dependencies in my embedded Python builds that has issues with Linux compatibility. I'm not sure if other Python builds have these issues. My understanding is that Firefox builds are dealing with this by statically building in libstdc++. The embedded Python build should do the same. Cheers, Trent -- Trent Mick trentm@xxxxxxxxxxxxxxx diff Disable the use of the main Python DLL embedded version string in (1) finding module names (via .../PythonCore/$winver/PythonPath/Modules/...) and (2) determining the sys.path. Generally, the latter means that apps embedding this Python should set PYTHONHOME in their environment before Python initializes itself. If this patch is to be proposed for the Python core then (a) it should be made a configurable #define and (b) consider changing the meaning of sys.winver to be None if the winver is NOT used for registry operations. Would have to update Modules/sysmodule.c and the docs for that. --- python/Python/import.c.original 2006-02-14 10:19:57.000000000 -0800 +++ python/Python/import.c 2006-02-14 10:20:08.000000000 -0800 @@ -1049,10 +1049,6 @@ corresponding filedescr struct, and (via return arguments) the pathname and an open file. Return NULL if the module is not found. */ -#ifdef MS_COREDLL -extern FILE *PyWin_FindRegisteredModule(const char *, struct filedescr **, - char *, int); -#endif static int case_ok(char *, int, int, char *); static int find_init_module(char *); /* Forward */ @@ -1155,13 +1151,6 @@ return &fd_frozen; } -#ifdef MS_COREDLL - fp = PyWin_FindRegisteredModule(name, &fdp, buf, buflen); - if (fp != NULL) { - *p_fp = fp; - return fdp; - } -#endif path = PySys_GetObject("path"); } if (path == NULL || !PyList_Check(path)) { --- python/PC/getpathp.c.original 2006-02-14 10:21:02.000000000 -0800 +++ python/PC/getpathp.c 2006-02-14 10:21:07.000000000 -0800 @@ -489,8 +489,6 @@ } skiphome = pythonhome==NULL ? 0 : 1; - machinepath = getpythonregpath(HKEY_LOCAL_MACHINE, skiphome); - userpath = getpythonregpath(HKEY_CURRENT_USER, skiphome); /* We only use the default relative PYTHONPATH if we havent anything better to use! */ skipdefault = envpath!=NULL || pythonhome!=NULL || \ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Python binaries for mozilla: 00015, Shane Caraveo |
|---|---|
| Previous by Thread: | Re: Python binaries for mozillai: 00015, Shane Caraveo |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |