views:

388

answers:

2

Hello,

I am using Python as a plug-in scripting language for an existing C++ application. I am able to embed the python interpreter as stated in the Python documentation. Everything works successfully with the initialization and de-initialization of the interpreter. I am, however, having trouble loading modules because I have not been able to zip up the standard library in to a zip file (normally PythonXX.zip, corresponding to the version number of the python dll).

What is the simplest way to zip up all of the standard library after optimized bytecode compiling? I'm looking for a simple script or command to do so for me, as I really don't want to do this by hand.

Any ideas?

Thanks!

+1  A: 

It shouldn't be too difficult to write a script for that. Check out the zipfile.PyZipFile class and it's writepy method.

theller
+1  A: 

I would probably use setuptools to create an egg (basically a java jar for python). The setup.py would probably look something like this:

from setuptools import setup, find_packages

setup(
    name='python26_stdlib',
    package_dir = {'' : '/path/to/python/lib/directory'},
    packages = find_packages(),
    #any other metadata
)

You could run this using python setup.py bdist_egg. Once you have the egg, you can either add it to the python path or you can install it using setuptools. I believe this should also handle the generation of pycs for you as well.

NOTE: I wouldn't use this on my system python directory. You might want to set up a virtualenv for this.

Jason Baker