How To Copy A Python Module And It's Dependencies To A File
I want to use a Python module like urllib.request but have all the module's dependencies in a file where I can use them on a computer without having the entire Python installation.
Solution 1:
There's a variety of options available to do this sort of thing. The one that comes to mind first off the top of my head is python's built-in zip support; if you have a __main__.py
in your zip, running python on the zip file will run it as a script. Simple (pure-python, non-OS-dependent) packages should be simply embeddable into such a zip file.
Alternatively, tools such as cx_Freeze can package a script with its dependencies including the interpreter in an OS-specific fashion. This will typically result in a larger footprint as the resulting bundle includes the interpreter as well, but allows including more complex dependencies with native components; I'm not sure this is possible with python's zip import functionality.
Post a Comment for "How To Copy A Python Module And It's Dependencies To A File"