Egg Patching Solution #2

I’ve been thinking more about patching Python eggs.  All I really need is for buildout.cfg to use a patched egg.  It doesn’t matter when the patching happens (although monkey patching is unacceptable; the changes I’m making are too complex for that.)  So the buildout process should download an egg that has already been patched.  That solution is probably less error-prone anyway.

So, I could create a “ZODB3-polling” egg that contains ZODB 3.8.1 with the invalidation polling patch, then upload that to PyPI.  All I have to do is tell people how to change their buildout.cfg to use my egg in place of the ZODB3 egg.

Ah, but there’s trouble: the ZODB3 egg is pulled in automatically through egg dependencies.  If people simply add my new egg to their buildout.cfg, they will end up with two ZODB versions in the Python path at once.  Which one wins?!

Therefore, it seems like zc.buildout should have a way to express, in buildout.cfg, “any requirement for egg X should instead be satisfied by egg Y”.  I am going to study how that might be done.

5 thoughts on “Egg Patching Solution #2”

  1. You could also perhaps make a patched egg available by having a special version number, ZODB3 with version “3.8.1-polling”, say.

    You should then be able to use buildout’s ‘versions’ mechanism to indicate your special version:

    versions = versions

    ZODB3 = 3.8.1-polling

    Of course you’d still need to make this ZODB3 version available somewhere. So either you’d need PyPy access for the ZODB3 package (but I think that could get confusing), or you need to supply your own index and add a ‘find-links’ to people’s buildouts. Then of course I’m not sure how easy_install goes and find a version, so all of this might or might not work.

  2. Ian: Unfortunately, I don’t yet see how pip helps. On the web page for pip I don’t see any explicit support for patching nor the ability to substitute one package for another. What am I missing?

  3. I’ve worked on collective.recipe.patch which patches both eggs and other parts. I commited some code to make it more general and use pure python but not sure if its realeased. Works well though.

  4. I was fighting a similar problem, wanting to have a patched setuptools. Not wanting to put it on a website, I made buildout look into my file system:

    find_links = patched_eggs/

    There is my special versioned egg.

Comments are closed.