[Distutils] including a third party egg without "installing" it
pje at telecommunity.com
Thu May 14 18:07:45 CEST 2009
At 10:56 PM 5/13/2009 -0500, Randall Smith wrote:
>I'd like to bundle some third party eggs with my application without
>installing them. Typically, I'd read __file__ and alter sys.path at
>runtime to include the third party packages, but I understand that
>will not work with zipped eggs.
>I don't know the best way to go about this, but I at least want to
>know a clean way to do it without requiring the third party eggs to
>be downloaded and installed separately. Consider this layout.
> From my current understanding about how setuptools works, I think I
> could treat the third party eggs as data files and and runtime
> (somehow?) insert them into the path and import them.
>I'm trying to work from this example.
>Is this a workable approach?
No. You need the eggs to be unzipped, and in the *root* of your
distributed egg, alongside your package. i.e.:
You can then simply use require() at runtime to access the bundled eggs.
> Is there a better way?
Yes. Simply install your entire application as eggs and scripts in a
single directory (using "easy_install -maxd somedir myapp") and then
tarball and ship "somedir". Less muss, less fuss, and no
require(). (I.e., just declare your dependencies in setup.py)
If you want to, you can even ship without needing setuptools
installed on the target machine - just copy the pkg_resources module
to "somedir" before you tarball it up.
More information about the Distutils-SIG