문제

I want to pack pure python library into one source python script. (not exe, app, etc. I need exactly lib.py file) Is it possible? Which tools are exist for this?

도움이 되었습니까?

해결책

Best is to pack all your python files into a zip: https://blogs.gnome.org/jamesh/2012/05/21/python-zip-files/

If you really want to, sure, it is possible to pack everything (including a zip I think) to a .py file, just write your custom importhook, store base64-encoded zip archive as a string in your since python source, a bit of hardcore magic here and there and voila, single python program,

Alternatively you could refactor all your dependencies and include these as classes for example in your source, but why bother?

Finally, there's no simple way to include compiled dependencies, i.e. those .so / .dylib / .dll files.

I don't think there is a tool out there that does exactly what you want, but I reckon pyinstaller/py2exe can be used to get pretty close, for example http://www.py2exe.org/old/ look for library.zip.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top