![](https://secure.gravatar.com/avatar/d7ff36e4d7c8060fadaa7c20f4a5649e.jpg?s=120&d=mm&r=g)
I thought it would be interesting to get an idea of the relative popularity of the various pkg_resources calls in the interest of emulating a subset. So I looked it up on Nullege. The absolute popularity is certainly different from the numbers below. I think of require() and load_entry_point() used in console scripts as implementing a dynamic linker, so for example if some code crashes when the KDEWallet bindings are installed, you would still be able to run it by omitting those from sys.path. Gem certainly works this way. I'm not 100% sure pkg_resources works that way. Those functions traverse the dependency graph at runtime which is fast because it doesn't include the "search pypi" stuff. resource_filename is very popular. I would have thought resource_stream would be more popular. Unless your package is zipped resource_filename is trivial to implement. If you are writing an installer, you can unpack a single distribution to a folder, run find_distributions() on that folder, and get a Distribution() object with the dependencies as a dict. -- Daniel H pkg_resources APIs by number of Nullege Call() counts: 'require', 2284 'run_script', 0 'get_provider', 32 'get_distribution', 103 'load_entry_point', 31 'get_entry_map', 11 'get_entry_info', 4 'iter_entry_points', 291 'resource_string', 175 'resource_stream', 155 'resource_filename', 713 'resource_listdir', 71 'resource_exists', 67 'resource_isdir', 18 'declare_namespace', 643; obsoleted by Python 3.3 or pkgutil 'working_set', 55 (all samples); not a function 'add_activation_listener', 3 'find_distributions', 25; needed by installers 'set_extraction_path', 2 'cleanup_resources', 4 'get_default_cache', 2 'Environment', 51 'WorkingSet', 17 'ResourceManager', 27 'Distribution', 22; needed by installers 'Requirement.parse', 524 'EntryPoint.parse', 45 'ResolutionError', 6 samples 'VersionConflict', 13 samples 'DistributionNotFound', 41 samples 'UnknownExtra', 8 samples 'ExtractionError', 0 'parse_requirements', 32 'parse_version', 100 'safe_name', trivial regexp replace 'safe_version', "" 'get_platform', 1 'compatible_platforms', 0 'yield_lines', 15; trivial 'split_sections', 9; .ini-style [section] parser 'safe_extra', 0; another regexp replacement 'to_filename', 9; another text replacement 'ensure_directory', 40 'normalize_path', 42 # Constants that control which kinds of dists are preferred 'EGG_DIST', 'BINARY_DIST', 'SOURCE_DIST', 'CHECKOUT_DIST', 'DEVELOP_DIST', 'IMetadataProvider', 'IResourceProvider', 'FileMetadata', 'PathMetadata', 23 'EggMetadata', 2 'EmptyProvider', 'empty_provider', 'NullProvider', subclassed a few times for unit test mocks 'EggProvider', 0 'DefaultProvider', 21 mentions 'ZipProvider', 1 subclass 'register_finder', 'register_namespace_handler', 'register_loader_type', 6; one user is a code signing library 'fixup_namespace_packages', 0 'get_importer', 0 'AvailableDistributions']