]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
bundled zetuptoolz: if __main__.__requires__ exists then do not add packages to the...
authordavid-sarah <david-sarah@jacaranda.org>
Fri, 29 Oct 2010 22:31:11 +0000 (15:31 -0700)
committerdavid-sarah <david-sarah@jacaranda.org>
Fri, 29 Oct 2010 22:31:11 +0000 (15:31 -0700)
setuptools-0.6c16dev2.egg/pkg_resources.py
setuptools-0.6c16dev2.egg/setuptools/command/easy_install.py

index f382adfeb8706b3a2ec61eb4f42ff40e48ef48c2..9828d8978fc20ed438870eb7f7a5719a7b5574db 100644 (file)
@@ -524,6 +524,16 @@ class WorkingSet(object):
         if dist.key in self.by_key:
             return      # ignore hidden distros
 
+        # If we have a __requires__ then we can already tell if this
+        # dist is unsatisfactory, in which case we won't add it.
+        if __requires__ is not None:
+            for thisreqstr in __requires__:
+                for thisreq in parse_requirements(thisreqstr):
+                    if thisreq.key == dist.key:
+                        if dist not in thisreq:
+                            return
+
+
         self.by_key[dist.key] = dist
         if dist.key not in keys:
             keys.append(dist.key)
@@ -2591,6 +2601,7 @@ def _initialize(g):
 _initialize(globals())
 
 # Prepare the master working set and make the ``require()`` API available
+__requires__ = None
 _declare_state('object', working_set = WorkingSet())
 try:
     # Does the main program list any requirements?
@@ -2601,12 +2612,15 @@ else:
     # Yes: ensure the requirements are met, by prefixing sys.path if necessary
     try:
         working_set.require(__requires__)
-    except VersionConflict:     # try it without defaults already on sys.path
+    except (VersionConflict, DistributionNotFound):     # try it without defaults already on sys.path
         working_set = WorkingSet([])    # by starting with an empty path
-        for dist in working_set.resolve(
-            parse_requirements(__requires__), Environment()
-        ):
-            working_set.add(dist)
+        try:
+            for dist in working_set.resolve(
+                parse_requirements(__requires__), Environment()
+                ):
+                working_set.add(dist)
+        except DistributionNotFound:
+            pass
         for entry in sys.path:  # add any missing entries from sys.path
             if entry not in working_set.entries:
                 working_set.add_entry(entry)
index a9be3fa301741fbfdfcfe00cf1825cb1225507a5..8ac42b4d29e9a1ad8785384b6d1ff77d1a4ba3cb 100644 (file)
@@ -584,10 +584,11 @@ Please make the appropriate changes for your system and try again.
         spec = str(dist.as_requirement())
         is_script = is_python_script(script_text, script_name)
 
+        requires = [spec] + [str(r) for r in dist.requires()]
         if is_script and dev_path:
             script_text = get_script_header(script_text) + (
                 "# EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r\n"
-                "__requires__ = %(spec)r\n"
+                "__requires__ = %(requires)r\n"
                 "from pkg_resources import require; require(%(spec)r)\n"
                 "del require\n"
                 "__file__ = %(dev_path)r\n"
@@ -596,7 +597,7 @@ Please make the appropriate changes for your system and try again.
         elif is_script:
             script_text = get_script_header(script_text) + (
                 "# EASY-INSTALL-SCRIPT: %(spec)r,%(script_name)r\n"
-                "__requires__ = %(spec)r\n"
+                "__requires__ = %(requires)r\n"
                 "import pkg_resources\n"
                 "pkg_resources.run_script(%(spec)r, %(script_name)r)\n"
             ) % locals()
@@ -1575,6 +1576,7 @@ def fix_jython_executable(executable, options):
 def get_script_args(dist, executable=sys_executable, wininst=False, script_dir=None):
     """Yield write_script() argument tuples for a distribution's entrypoints"""
     spec = str(dist.as_requirement())
+    requires = [spec] + [str(r) for r in dist.requires()]
     header = get_script_header("", executable, wininst)
     generated_by = "# generated by zetuptoolz %s" % (setuptools_version,)
 
@@ -1583,7 +1585,7 @@ def get_script_args(dist, executable=sys_executable, wininst=False, script_dir=N
             script_head, script_tail = ((
                 "# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r\n"
                 "%(generated_by)s\n"
-                "__requires__ = %(spec)r\n"
+                "__requires__ = %(requires)r\n"
                 "import sys\n"
                 "from pkg_resources import load_entry_point\n"
                 "\n"