Commits

Daniel Holth  committed db913ec

include an install-scripts command to redo console_scripts

  • Participants
  • Parent commits 34d170e

Comments (0)

Files changed (2)

File wheel/paths.py

 import distutils.dist as dist
 import distutils.command.install as install
 
+def get_install_command(name):
+    # late binding due to potential monkeypatching
+    d = dist.Distribution({'name':name})
+    i = install.install(d)
+    i.finalize_options()
+    return i
+
 def get_install_paths(name):
     """
     Return the (distutils) install paths for the named dist.
     
     A dict with ('purelib', 'platlib', 'headers', 'scripts', 'data') keys.
-    """    
+    """
     paths = {}
 
-    # late binding due to potential monkeypatching
-    d = dist.Distribution({'name':name})
-    i = install.install(d)
-    i.finalize_options()
+    i = get_install_command(name)
+
     for key in install.SCHEME_KEYS:
-        paths[key] = getattr(i, 'install_'+key)
-        
-    # pip uses a similar path as an alternative to the system's (read-only) 
+        paths[key] = getattr(i, 'install_' + key)
+
+    # pip uses a similar path as an alternative to the system's (read-only)
     # include directory:
-    if hasattr(sys, 'real_prefix'): # virtualenv
-        paths['headers'] = os.path.join(sys.prefix, 
-                                        'include', 
-                                        'site', 
+    if hasattr(sys, 'real_prefix'):  # virtualenv
+        paths['headers'] = os.path.join(sys.prefix,
+                                        'include',
+                                        'site',
                                         'python' + sys.version[:3],
                                         name)
 

File wheel/tool/__init__.py

 import hashlib
 import sys
 import json
+import wheel.paths
+
 from glob import iglob
 from .. import signatures
 from ..util import (urlsafe_b64decode, urlsafe_b64encode, native, binary,
         wf.install(force=force)
         wf.zipfile.close()
 
+def install_scripts(distributions):
+    """
+    Regenerate the entry_points console_scripts for the named distribution.
+    """
+    try:
+        from setuptools.command import easy_install
+        import pkg_resources
+    except ImportError:
+        raise RuntimeError("'wheel install_scripts' needs setuptools.")
+
+    for dist in distributions:
+        pkg_resources_dist = pkg_resources.get_distribution(dist)
+        install = wheel.paths.get_install_command(dist)
+        command = easy_install.easy_install(install.distribution)
+        command.args = ['wheel'] # dummy argument
+        command.finalize_options()
+        command.install_egg_scripts(pkg_resources_dist)
+
 def convert(installers, dest_dir, verbose):
     if not have_pkgresources:
         raise RuntimeError("'wheel convert' needs pkg_resources (part of setuptools).")
                                 "but don't actually install anything.")
     install_parser.set_defaults(func=install_f)
 
+    def install_scripts_f(args):        
+        install_scripts(args.distributions)
+    install_scripts_parser = s.add_parser('install-scripts', help='Install console_scripts')
+    install_scripts_parser.add_argument('distributions', nargs='*',
+                                        help='Regenerate console_scripts for these distributions')
+    install_scripts_parser.set_defaults(func=install_scripts_f)
+
     def convert_f(args):
         convert(args.installers, args.dest_dir, args.verbose)
     convert_parser = s.add_parser('convert', help='Convert egg or wininst to wheel')