Skip to content

Instantly share code, notes, and snippets.

@pcwalton
Created May 28, 2010 17:45
Show Gist options
  • Save pcwalton/417469 to your computer and use it in GitHub Desktop.
Save pcwalton/417469 to your computer and use it in GitHub Desktop.
def get_package_lists(self):
"""Returns a pair consisting of all packages, followed by a dictionary
mapping each package name to "static" or "dynamic"."""
# Filter the packages into static and dynamic parts. If a package is
# dynamically loaded, all of its dependencies must also be dynamically
# loaded. We use a simple greedy algorithm.
root_names = self.static_plugins + self.dynamic_plugins
roots = dict([ name, self.get_package(name) for name in root_names ])
all_packages = self.get_dependencies(roots.values())
dynamic_roots = [ roots[name] for name in self.dynamic_plugins ]
dynamic_packages = self.get_dependencies(dynamic_roots)
dynamic_names = set([ pkg.name for pkg in dynamic_packages ])
def get_type(name):
return 'dynamic' if name in dynamic_names else 'static'
all_names = [ pkg.name for pkg in all_packages ]
types = dict([ name, get_type(name) for name in all_names ])
return all_packages, types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment