At 05:42 AM 2/19/2008 -0800, Tarek Ziadé wrote:
Hello,
I am trying to write a script that removes all traces of an egg. I am not talking about a clever thing that follows dependencies, but I have faced issues where my fellow developers had a remaining "develop" eggs that had to be removed.
Develop eggs can (and should!) be uninstalled using "setup.py develop -u".
So an "easy_remove" script that cleanly erase all occurences of a given egg would be good ihmo.
In my understanding, the script should:
- scan all entries in pkg_resources.working_set.entries, to get all instances of the given egg (folder, archive and link)
- call easy_install -m package
- remove all entries founded before.
Is that right ?
It would probably be simpler to just read and edit a specific easy-install.pth file, using ``pkg_resources.find_distributions(path, True)``. If you find a matching distribution, remove the line from the file, and the egg file/directory if appropriate. (Of course, you will need to skip lines beginning with "import ", and leave them in place.) If you want to remove all eggs for a project, whether active or not, you can indeed scan everything on sys.path. The easiest way to do that is just to do: for dist in pkg_resources.Environment()[project_name]: # rm -rf dist.location if appropriate Of course, you will need to make sure you only delete a distribution (in either case) if ``dist.precedence==pkg_resources.EGG_DIST``.