[Distutils] Adding egg support (Resource API) to existing packages

Kevin Dangoor dangoor at gmail.com
Thu Jul 14 17:56:34 CEST 2005


On 7/14/05, Paul Moore <p.f.moore at gmail.com> wrote:
> You don't care about eggs (yet). Your users (one of whom is me) do,
> and would like to package your code in an egg via python setup.py
> --compiler-package=setuptools.command bdist_egg. This works fine, with
> no source changes, but the resulting egg isn't zip-safe because of
> resource usage issues.

While I agree with Phillip on this one, I do know what you're saying.
I've wondered that about some of the packages I'm putting into eggs.

I'm pretty certain this situation will arise where a project
maintainer won't go for a setuptools dependency. Here's one way to
deal with it:

Let's say the project's code is in the package:

pythonfoobar

What if you toss pkg_resources into pythonfoobar. Then, in all of the
modules you touch, you just do:

from pythonfoobar import pkg_resources

Then, once the package maintainer comes to his or her senses and
realizes that the world is A Better Place With Eggs (tm), there are
two simple ways to introduce the setuptools dependency:

1) project wide search and replace
2) in pythonfoobar/__init__ just import pkg_resources  (this is
assuming you're not using the fancy setuptools namespaces... not many
projects need that, though.)

Ideally, people will go along with setuptools. But, at least this
workaround won't break people's systems.

Kevin


More information about the Distutils-SIG mailing list