summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Holth <dholth@fastmail.fm>2013-07-19 19:01:43 -0400
committerDaniel Holth <dholth@fastmail.fm>2013-07-19 19:01:43 -0400
commit4ea1d315fedcbc6fc1c1661bae7ab728fbe1b459 (patch)
tree4af7bfd56cd214de283bdecb4de42f4db5d406a7
parent54e08f0cbc7bfdaee47c191312a2415b4c85cb3c (diff)
downloadwheel-4ea1d315fedcbc6fc1c1661bae7ab728fbe1b459.tar.gz
include an install-scripts command to redo console_scripts
-rw-r--r--wheel/paths.py29
-rw-r--r--wheel/tool/__init__.py27
2 files changed, 44 insertions, 12 deletions
diff --git a/wheel/paths.py b/wheel/paths.py
index 3444989..fe3dfd6 100644
--- a/wheel/paths.py
+++ b/wheel/paths.py
@@ -9,27 +9,32 @@ import sys
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)
diff --git a/wheel/tool/__init__.py b/wheel/tool/__init__.py
index 5e52efb..54c602d 100644
--- a/wheel/tool/__init__.py
+++ b/wheel/tool/__init__.py
@@ -6,6 +6,8 @@ import os
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,
@@ -220,6 +222,24 @@ def install(requirements, requirements_file=None,
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).")
@@ -294,6 +314,13 @@ def parser():
"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')