--- old-trunk/setup.py	2010-10-15 00:30:26.000000000 -0600
+++ new-trunk/setup.py	2010-10-15 00:30:27.000000000 -0600
@@ -38,6 +38,20 @@
 
 version = read_version_py("src/allmydata/_version.py")
 
+# setuptools/zetuptoolz looks in __main__.__requires__ for a list of
+# requirements. When running "python setup.py test", __main__ is
+# setup.py, so we put the list here so that the requirements will be
+# available for tests:
+
+# Tahoe's dependencies are managed by the find_links= entry in setup.cfg and
+# the _auto_deps.install_requires list, which is used in the call to setup()
+# below.
+adglobals = {}
+execfile('src/allmydata/_auto_deps.py', adglobals)
+install_requires = adglobals['install_requires']
+
+__requires__ = install_requires
+
 egg = os.path.realpath(glob.glob('setuptools-*.egg')[0])
 sys.path.insert(0, egg)
 egg = os.path.realpath(glob.glob('darcsver-*.egg')[0])
@@ -319,13 +333,6 @@
 
         return sdist.sdist.make_distribution(self)
 
-# Tahoe's dependencies are managed by the find_links= entry in setup.cfg and
-# the _auto_deps.install_requires list, which is used in the call to setup()
-# below.
-adglobals = {}
-execfile('src/allmydata/_auto_deps.py', adglobals)
-install_requires = adglobals['install_requires']
-
 APPNAME='allmydata-tahoe'
 APPNAMEFILE = os.path.join('src', 'allmydata', '_appname.py')
 APPNAMEFILESTR = "__appname__ = '%s'" % (APPNAME,)
--- old-trunk/setuptools-0.6c16dev2.egg/setuptools/command/easy_install.py	2010-10-15 00:30:26.000000000 -0600
+++ new-trunk/setuptools-0.6c16dev2.egg/setuptools/command/easy_install.py	2010-10-15 00:30:27.000000000 -0600
@@ -584,10 +584,11 @@
         spec = str(dist.as_requirement())
         is_script = is_python_script(script_text, script_name)
 
+        requires = [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 @@
         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 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 = [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 @@
             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"
diff -rN -u old-trunk/src/allmydata/scripts/create_node.py new-trunk/src/allmydata/scripts/create_node.py
--- old-trunk/src/allmydata/scripts/create_node.py	2010-10-15 00:30:26.000000000 -0600
+++ new-trunk/src/allmydata/scripts/create_node.py	2010-10-15 00:30:28.000000000 -0600
@@ -28,11 +28,13 @@
         ["node-directory", "d", None, "Specify which directory the introducer should be created in. [no default]"],
     ]
 
-client_tac = """
+client_tac_templ = """
 # -*- python -*-
 
+__requires__ = %(requires)r
+
 import pkg_resources
-pkg_resources.require('%s')
+pkg_resources.require('%(appname)s')
 pkg_resources.require('twisted')
 from allmydata import client
 from twisted.application import service
@@ -41,7 +43,10 @@
 
 application = service.Application("allmydata_client")
 c.setServiceParent(application)
-""" % (allmydata.__appname__,)
+"""
+from __main__ import __requires__
+
+client_tac = client_tac_templ % { 'requires': __requires__, 'appname': allmydata.__appname__, }
 
 introducer_tac = """
 # -*- python -*-
diff -rN -u old-trunk/src/allmydata/scripts/keygen.py new-trunk/src/allmydata/scripts/keygen.py
--- old-trunk/src/allmydata/scripts/keygen.py	2010-10-15 00:30:26.000000000 -0600
+++ new-trunk/src/allmydata/scripts/keygen.py	2010-10-15 00:30:28.000000000 -0600
@@ -11,9 +11,11 @@
         ["node-directory", "d", None, "Specify which directory the key-generator should be created in. [no default]"],
     ]
 
-keygen_tac = """
+keygen_tac_templ = """
 # -*- python -*-
 
+__requires__ = %(requires)s
+
 import pkg_resources
 pkg_resources.require('allmydata-tahoe')
 
@@ -29,6 +31,10 @@
 k.setServiceParent(application)
 """
 
+from __main__ import __requires__
+
+keygen_tac = keygen_tac_templ % { 'requires': __requires__ }
+
 def create_key_generator(basedir, config, out=sys.stdout, err=sys.stderr):
     # This should always be called with an absolute Unicode basedir.
     precondition(isinstance(basedir, unicode), basedir)
