What is the easiest way to create Python26.zip for an embedded distribution?

I use Python as a plugin scripting language for an existing C ++ application. I can embed a python interpreter as indicated in the Python documentation. Everything works successfully with initialization and deinitialization of the interpreter. However, I have problems loading the modules, because I could not put the standard library into a zip file (usually PythonXX.zip, corresponding to the python dll version number).

What is the easiest way to zip an entire standard library after optimizing bytecode compilation? I am looking for a simple script or command to do this for me, as I really do not want to do this manually.

Any ideas?

Thanks!

+3
source share
2 answers

It should not be too difficult to write a script for this. Check out the class zipfile.PyZipFileand method writepy.

+2
source

I would use setuptools to create an egg (basically java jar for python). Probably setup.py looks 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 can run this with python setup.py bdist_egg. When you have an egg, you can add it to the python path or install it using setuptools. I believe this should also apply to generating pycs for you.

. python. virtualenv .

+2

Source: https://habr.com/ru/post/1707120/


All Articles