#!/usr/bin/env python
-import os, sys, re
+import os, sys, re, glob
+
+def read_version_py(infname):
+ try:
+ verstrline = open(infname, "rt").read()
+ except EnvironmentError:
+ return None
+ else:
+ VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
+ mo = re.search(VSRE, verstrline, re.M)
+ if mo:
+ return mo.group(1)
+
+version = read_version_py(os.path.join('..', 'src', 'allmydata', '_version.py'))
+
+if version is None:
+ raise AssertionError("We don't know which version we're supposed to be testing.")
+
+APPNAME='allmydata-tahoe'
+
+adglobals = {}
+execfile(os.path.join('..', 'src', 'allmydata', '_auto_deps.py'), adglobals)
+install_requires = adglobals['install_requires']
+test_requires = adglobals.get('test_requires', ['mock'])
+
+# setuptools/zetuptoolz looks in __main__.__requires__ for a list of
+# requirements.
+
+__requires__ = [APPNAME + '==' + version] + install_requires + test_requires
+
+print "Requirements: %r" % (__requires__,)
+
+eggz = glob.glob('setuptools-*.egg')
+if len(eggz) > 0:
+ egg = os.path.realpath(eggz[0])
+ print "Inserting egg on sys.path: %r" % (egg,)
+ sys.path.insert(0, egg)
+
+import pkg_resources
modulename = None
for i in xrange(1, len(sys.argv)):
srcdir = os.path.normcase(os.path.normpath(srcdir))
cwd = os.path.normcase(os.path.normpath(os.getcwd()))
+if os.path.normcase(os.path.basename(cwd)) == 'src':
+ cwd = os.path.dirname(cwd)
+
same = (srcdir == cwd)
if not same:
try:
version = read_version_py("src/allmydata/_version.py")
+APPNAME='allmydata-tahoe'
+APPNAMEFILE = os.path.join('src', 'allmydata', '_appname.py')
+APPNAMEFILESTR = "__appname__ = '%s'" % (APPNAME,)
+try:
+ curappnamefilestr = open(APPNAMEFILE, 'rU').read()
+except EnvironmentError:
+ # No file, or unreadable or something, okay then let's try to write one.
+ open(APPNAMEFILE, "w").write(APPNAMEFILESTR)
+else:
+ if curappnamefilestr.strip() != APPNAMEFILESTR:
+ print "Error -- this setup.py file is configured with the 'application name' to be '%s', but there is already a file in place in '%s' which contains the contents '%s'. If the file is wrong, please remove it and setup.py will regenerate it and write '%s' into it." % (APPNAME, APPNAMEFILE, curappnamefilestr, APPNAMEFILESTR)
+ sys.exit(-1)
+
+# 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']
+
+if len(sys.argv) > 1 and sys.argv[1] in ['trial', 'test'] and version is not None:
+ __requires__ = [APPNAME + '==' + version] + 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])
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,)
-try:
- curappnamefilestr = open(APPNAMEFILE, 'rU').read()
-except EnvironmentError:
- # No file, or unreadable or something, okay then let's try to write one.
- open(APPNAMEFILE, "w").write(APPNAMEFILESTR)
-else:
- if curappnamefilestr.strip() != APPNAMEFILESTR:
- print "Error -- this setup.py file is configured with the 'application name' to be '%s', but there is already a file in place in '%s' which contains the contents '%s'. If the file is wrong, please remove it and setup.py will regenerate it and write '%s' into it." % (APPNAME, APPNAMEFILE, curappnamefilestr, APPNAMEFILESTR)
- sys.exit(-1)
-
setup_args = {}
if version:
setup_args["version"] = version