> I realise now that this "nice" solution won't work, as the standard > library code says: > > import socketserver > > so modifying sys.path will just change the value of > sys.modules["socketserver"]. However, the vendored code instead loads > this module to sys.modules["_pydev_imps._pydev_SocketServer"] or > something like that, deliberately avoiding interfering with > sys.modules["socketserver"].
It seems to me that the "correct" solution would be to motivate upstream not to vendor anything in their source tree. If they really need vendoring to avoid compatibility issues with various environments, they should do so only when building releases. It still wouldn't solve the problem of incompatible system modules, but at least it would make it clearer which versions they require and why. Perhaps they have a maintenance script for updating the vendored dependencies? You could use that to find out how to reverse the changes, or start from a clean slate?