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.