Folks: We're gradually converting the allmydata.org tahoe project [1] and its spin-off packages to use setuptools. One problem that comes up is that ez_setup.py might require a newer version of setuptools than the version of setuptools already installed. For example, although Tahoe currently uses setuptools to manage its dependencies on zfec, foolscap, and nevow [2], but if we execute simplejson's ez_setup.py then it requires setuptools v0.6c7 and refuses to proceed if an earlier version is installed. One solution for this problem could be for the packager of simplejson (Bob Ippolito) to use the "min_version" patch that we contributed to ez_setup.py [3]. This is assuming that simplejson doesn't actually *require* the latest version of setuptools, and we could successfully install with a slightly older version, but what if a package actually does require a newer version of setuptools than the one that is already installed? The following patch was created by Tahoe contributor Arno Washck and then modified by me in order to get around such a problem. The idea is simple enough -- reload setuptools. There may be some subtleties that we still need to work out. This patch hasn't been tested in its current form. --- ez_setup.py~ 2007-09-10 12:36:30.000000000 -0600 +++ ez_setup.py 2007-09-18 15:15:23.000000000 -0600 @@ -95,13 +95,9 @@ pkg_resources.require("setuptools>="+version) except pkg_resources.VersionConflict, e: - # XXX could we install in a subprocess here? - print >>sys.stderr, ( - "The required version of setuptools (>=%s) is not available, and\n" - "can't be installed while this script is running. Please install\n" - " a more recent version first.\n\n(Currently using %r)" - ) % (version, e.args[0]) - sys.exit(2) + egg = download_setuptools(version, download_base, to_dir, download_delay) + sys.path.insert(0, egg) + reload(setuptools); setuptools.bootstrap_install_from = egg def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, ------- An alternative idea figure out the version of the current install of setuptools without importing the package. The following patch might accomplish that. It is also not tested. --- ez_setup.py~ 2007-09-10 12:36:30.000000000 -0600 +++ ez_setup.py 2007-09-18 15:26:50.000000000 -0600 @@ -77,31 +77,13 @@ this routine will print a message to ``sys.stderr`` and raise SystemExit in an attempt to abort the calling script. """ - try: - import setuptools - if setuptools.__version__ == '0.0.1': - print >>sys.stderr, ( - "You have an obsolete version of setuptools installed. Please\n" - "remove it from your system entirely before rerunning this script." - ) - sys.exit(2) - except ImportError: - egg = download_setuptools(version, download_base, to_dir, download_delay) - sys.path.insert(0, egg) - import setuptools; setuptools.bootstrap_install_from = egg - + verstr = os.system("python -c \"import setuptools;print setuptools.__version__\"") import pkg_resources - try: - pkg_resources.require("setuptools>="+version) - except pkg_resources.VersionConflict, e: - # XXX could we install in a subprocess here? - print >>sys.stderr, ( - "The required version of setuptools (>=%s) is not available, and\n" - "can't be installed while this script is running. Please install\n" - " a more recent version first.\n\n(Currently using %r)" - ) % (version, e.args[0]) - sys.exit(2) + if pkg_resources.parse_version(verstr) < pkg_resources.parse_version(version): + egg = download_setuptools(version, download_base, to_dir) + sys.path.insert(0, egg) + import setuptools; setuptools.bootstrap_install_from = egg def download_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, ------- Regards, Zooko [1] http://allmydata.org [2] http://allmydata.org/trac/tahoe/browser/calcdeps.py [3] http://mail.python.org/pipermail/distutils-sig/2007-September/ 008257.html