From: zooko Date: Sat, 22 Dec 2007 04:38:42 +0000 (+0530) Subject: zfec: setup: copy in latest version of ez_setup.py, which works even if setuptools... X-Git-Url: https://git.rkrishnan.org/pf/components/com_hotproperty/css/index.php?a=commitdiff_plain;h=82b9a8b407495a0fc09f7823a7c0ae42ca110097;p=tahoe-lafs%2Fzfec.git zfec: setup: copy in latest version of ez_setup.py, which works even if setuptools has been imported into the current Python interpreter but cannot be imported into another one in a subprocess darcs-hash:e840d057bcf9a3e24b36f63d4642ce5de735317b --- diff --git a/zfec/ez_setup.py b/zfec/ez_setup.py index de9a8a0..6dd60f9 100755 --- a/zfec/ez_setup.py +++ b/zfec/ez_setup.py @@ -68,10 +68,33 @@ def parse_version(s): def setuptools_is_new_enough(required_version): """Return True if setuptools is already installed and has a version number >= required_version.""" - (cin, cout, cerr,) = os.popen3("%s -c \"import os,sys; sys.path.extend([x for x in os.listdir('.') if x.endswith('.egg')] ; import setuptools;print setuptools.__version__\"" % (sys.executable,)) - verstr = cout.read().strip() - ver = parse_version(verstr) - return ver and ver >= parse_version(required_version) + if 'pkg_resources' in sys.modules: + import pkg_resources + try: + pkg_resources.require('setuptools >= %s' % (required_version,)) + except pkg_resources.VersionConflict: + # An insufficiently new version is installed. + return False + else: + return True + else: + try: + import pkg_resources + except ImportError: + # Okay it is not installed. + return False + else: + try: + pkg_resources.require('setuptools >= %s' % (required_version,)) + except pkg_resources.VersionConflict: + # An insufficiently new version is installed. + pkg_resources.__dict__.clear() # "If you want to be absolutely sure... before deleting it." --said PJE on IRC + del sys.modules['pkg_resources'] + return False + else: + pkg_resources.__dict__.clear() # "If you want to be absolutely sure... before deleting it." --said PJE on IRC + del sys.modules['pkg_resources'] + return True def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,