At 11:37 AM 6/23/2006 -0400, Jim Fulton wrote:
I have a script based on setuptools that invokes easy install to check for and download newer distributions. I allow users to specify whether or not they want unzipped downloads. As a result, easy_install will sometimes replace a zip file with a directory or the other way around. This leads to problems in the invoking program because the sys.path_importer_cache is stale. Does anyone know if it is safe to clear the cache from time to time? If so, I'd be inclined to clear it any time I invoke easy_install.
Hm. easy_install should be doing this itself... oh wait, it's clearing the *zip directory cache*, which fixes the problem of overwriting a zip with a zip. You're having a problem when overwriting a zip with a directory. Now I understand why sometimes I still get reports of behavior that resembles this problem, but then they aren't reproducible. I'll fix easy_install to also clear the path importer cache for a path entry when it clears the zip directory cache for that entry. (And to answer your general question, it's fine to clear the path_importer_cache, per PEP 302's advice to do so whenever you add new import hooks. It just slows down the next import search a bit.)