[Bf-committers] Extra Python modules

Willian Padovani Germano bf-committers@blender.org
Tue, 27 Jan 2004 06:13:49 -0200


Hi,

As most or all of you know well, some scripts try to import modules that
are not part of Blender and require full Python installations.

Last meeting I mentioned we could compile a Python library with more
builtin modules, but that's not necessary, we can use a mix of .py files
and dynamic libs (.pyd under win) to bundle more standard pymodules with
Blender.

I made a quick test with Python 2.2.1 and an old Publisher 2.25 I have
under win98, here.  It was not a proper test, but showed how this can be
done.  We just need to put all wanted modules and their dependencies
somewhere where bpython can find them -- e.g.: .blender/scripts/ .

In a zipped file with mere 51k, I got the following modules: os, random,
gzip, StringIO, chunk, plus their non-builtin dependencies on windows:
ntpath, stat, UserDict, types, __future__ and the zlib dll.  Only issue
until now is that the .pyd DLLs must, as expected, belong to the same
Python version linked against Blender.

Of course, only when Blender changes the Python version it links to,
this extra package would have to be updated, but being < 100k, probably
Ton will prefer it included with the win Blender binaries.

--
Willian, wgermano@ig.com.br

=====================================

BG: when we link Blender with Python, we only get a few statically
linked modules, referenced then as builtin:

# pycode
import sys
print sys.builtin_module_names
#

Here for win98 and Python 2.2 this prints:

('__builtin__', '__main__', '_codecs', '_hotshot', '_locale',
'_weakref', 'array', 'audioop', 'binascii', 'cPickle', 'cStringIO',
'cmath', 'errno', 'exceptions', 'gc', 'imageop', 'imp', 'marshal',
'math', 'md5', 'msvcrt', 'new', 'nt', 'operator', 'pcre', 'regex',
'rgbimg', 'rotor', 'sha', 'signal', 'strop', 'struct', 'sys', 'thread',
'time', 'xreadlines', 'xxsubtype')

For linux the list is much smaller, most modules are built as shared,
since there Python might already be considered a standard component.
Also, some modules are specific to one platform.