
At 11:19 PM 3/9/2009 -0400, David Lyon wrote:
What I want to do is use these in a list of installed packages. And then later provide for deinstallation. I'm thinking of parsing this file to read all the package names..
My question is is there any way to do the same thing with setuptools?
http://peak.telecommunity.com/DevCenter/PkgResources#workingset-objects You can simply iterate over pkg_resources.working_set to obtain Distribution objects for all eggs on sys.path -- that will give you all *activated* packages (i.e., ones listed in .pth files or otherwise explicitly on sys.path). If you want all *installed* packages (which may not be on sys.path, but are still physically present in a directory on sys.path), you want an Environment object instead: http://peak.telecommunity.com/DevCenter/PkgResources#environment-objects And to remove a package from the .pth file, you can use "easy_install -mxNd targetdir project==version" -- this will remove the named project from the easy-install.pth file in targetdir. (The -m takes it out, the -x means don't reinstall scripts, the -N means don't install dependencies, and the -d targetdir specifies where the .pth file is.)