Skip to content

Commit

Permalink
add --egg option to opt out --single-version-externally-managed
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalmustafa committed May 20, 2012
1 parent e0db44e commit 93cd6b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 7 additions & 0 deletions pip/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ def __init__(self):
action='store_true',
help='Install to user-site')

self.parser.add_option(
'--egg',
dest='as_egg',
action='store_true',
help="Install as self contained egg file, like easy_install does.")

def _build_package_finder(self, options, index_urls):
"""
Create a package finder appropriate to this install command.
Expand Down Expand Up @@ -206,6 +212,7 @@ def run(self, options, args):
download_dir=options.download_dir,
download_cache=options.download_cache,
upgrade=options.upgrade,
as_egg=options.as_egg,
ignore_installed=options.ignore_installed,
ignore_dependencies=options.ignore_dependencies,
force_reinstall=options.force_reinstall)
Expand Down
12 changes: 9 additions & 3 deletions pip/req.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
class InstallRequirement(object):

def __init__(self, req, comes_from, source_dir=None, editable=False,
url=None, update=True):
url=None, as_egg=False, update=True):
self.extras = ()
if isinstance(req, string_types):
req = pkg_resources.Requirement.parse(req)
Expand All @@ -45,6 +45,7 @@ def __init__(self, req, comes_from, source_dir=None, editable=False,
self.source_dir = source_dir
self.editable = editable
self.url = url
self.as_egg = as_egg
self._egg_info_path = None
# This holds the pkg_resources.Distribution object if this requirement
# is already available:
Expand Down Expand Up @@ -556,6 +557,7 @@ def install(self, install_options, global_options=()):
if self.editable:
self.install_editable(install_options, global_options)
return

temp_location = tempfile.mkdtemp('-record', 'pip-')
record_filename = os.path.join(temp_location, 'install-record.txt')
try:
Expand All @@ -565,9 +567,11 @@ def install(self, install_options, global_options=()):
"exec(compile(open(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))" % self.setup_py] +\
list(global_options) + [
'install',
'--single-version-externally-managed',
'--record', record_filename]

if not self.as_egg:
install_args += ['--single-version-externally-managed']

if running_under_virtualenv():
## FIXME: I'm not sure if this is a reasonable location; probably not
## but we can't put it in the default location, as that is a virtualenv symlink that isn't writable
Expand Down Expand Up @@ -781,7 +785,7 @@ def __repr__(self):
class RequirementSet(object):

def __init__(self, build_dir, src_dir, download_dir, download_cache=None,
upgrade=False, ignore_installed=False,
upgrade=False, ignore_installed=False, as_egg=False,
ignore_dependencies=False, force_reinstall=False):
self.build_dir = build_dir
self.src_dir = src_dir
Expand All @@ -798,6 +802,7 @@ def __init__(self, build_dir, src_dir, download_dir, download_cache=None,
self.successfully_downloaded = []
self.successfully_installed = []
self.reqs_to_cleanup = []
self.as_egg = as_egg

def __str__(self):
reqs = [req for req in self.requirements.values()
Expand All @@ -807,6 +812,7 @@ def __str__(self):

def add_requirement(self, install_req):
name = install_req.name
install_req.as_egg = self.as_egg
if not name:
self.unnamed_requirements.append(install_req)
else:
Expand Down

0 comments on commit 93cd6b1

Please sign in to comment.