code: def _build_egg(egg, archive_filename, to_dir):
      
      with archive_context(archive_filename):
          # building an egg
          log.warn('Building a Setuptools egg in %s', to_dir)
          _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
      # returning the result
      log.warn(egg)
      if not os.path.exists(egg):
          raise IOError('Could not build the egg.')
docs: Build Setuptools egg.