diff --git a/bootstrap.py b/bootstrap-buildout.py similarity index 72% rename from bootstrap.py rename to bootstrap-buildout.py index 2ec152f662355e3288f20f1a80afcdd710cfdea5..a629566735c1c84fbec7173f0f30015b2b432512 100644 --- a/bootstrap.py +++ b/bootstrap-buildout.py @@ -56,6 +56,11 @@ parser.add_option("-c", "--config-file", "file to be used.")) parser.add_option("-f", "--find-links", help=("Specify a URL to search for buildout releases")) +parser.add_option("--allow-site-packages", + action="store_true", default=False, + help=("Let bootstrap.py use existing site packages")) +parser.add_option("--setuptools-version", + help="use a specific setuptools version") options, args = parser.parse_args() @@ -63,45 +68,42 @@ options, args = parser.parse_args() ###################################################################### # load/install setuptools -to_reload = False try: - import pkg_resources - import setuptools + if options.allow_site_packages: + import setuptools + import pkg_resources + from urllib.request import urlopen except ImportError: - ez = {} - - try: - from urllib.request import urlopen - except ImportError: - from urllib2 import urlopen - - # XXX use a more permanent ez_setup.py URL when available. - exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py' - ).read(), ez) - setup_args = dict(to_dir=tmpeggs, download_delay=0) - ez['use_setuptools'](**setup_args) - - if to_reload: - reload(pkg_resources) - import pkg_resources - # This does not (always?) update the default working set. We will - # do it. - for path in sys.path: - if path not in pkg_resources.working_set.entries: - pkg_resources.working_set.add_entry(path) + from urllib2 import urlopen -###################################################################### -# Try to best guess the version of buildout given setuptools -if options.version is None: - - try: - from distutils.version import LooseVersion - package = pkg_resources.require('setuptools')[0] - v = LooseVersion(package.version) - if v < LooseVersion('0.7'): - options.version = '2.1.1' - except: - pass +ez = {} +exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) + +if not options.allow_site_packages: + # ez_setup imports site, which adds site packages + # this will remove them from the path to ensure that incompatible versions + # of setuptools are not in the path + import site + # inside a virtualenv, there is no 'getsitepackages'. + # We can't remove these reliably + if hasattr(site, 'getsitepackages'): + for sitepackage_path in site.getsitepackages(): + sys.path[:] = [x for x in sys.path if sitepackage_path not in x] + +setup_args = dict(to_dir=tmpeggs, download_delay=0) + +if options.setuptools_version is not None: + setup_args['version'] = options.setuptools_version + +ez['use_setuptools'](**setup_args) +import setuptools +import pkg_resources + +# This does not (always?) update the default working set. We will +# do it. +for path in sys.path: + if path not in pkg_resources.working_set.entries: + pkg_resources.working_set.add_entry(path) ###################################################################### # Install buildout @@ -132,10 +134,15 @@ if version is None and not options.accept_buildout_test_releases: _final_parts = '*final-', '*final' def _final_version(parsed_version): - for part in parsed_version: - if (part[:1] == '*') and (part not in _final_parts): - return False - return True + try: + return not parsed_version.is_prerelease + except AttributeError: + # Older setuptools + for part in parsed_version: + if (part[:1] == '*') and (part not in _final_parts): + return False + return True + index = setuptools.package_index.PackageIndex( search_path=[setuptools_path]) if find_links: @@ -162,8 +169,7 @@ cmd.append(requirement) import subprocess if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: raise Exception( - "Failed to execute command:\n%s", - repr(cmd)[1:-1]) + "Failed to execute command:\n%s" % repr(cmd)[1:-1]) ###################################################################### # Import and run buildout diff --git a/buildout.cfg b/buildout.cfg index 2426150ae2025fb628f4158b4ed0ed27cf1d6886..d3be9e410fc2a2854c5690636acd8cd691ef6f35 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -5,7 +5,8 @@ [buildout] parts = scripts develop = . -eggs = xbob.db.replay +eggs = bob + xbob.db.replay newest = false [scripts] diff --git a/setup.py b/setup.py index 3b0ed4484df5b3048646364ae38338e326caa967..126f4b80dadbaa10acf2684106a493749d79300e 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages setup( name='xbob.db.replay', - version='1.0.4', + version='1.0.5', description='Replay Attack Database Access API for Bob', url='http://pypi.python.org/pypi/xbob.db.replay', license='GPLv3', @@ -27,7 +27,7 @@ setup( 'setuptools', 'six', 'bob >= 1.1.0', - 'antispoofing.utils', + 'antispoofing.utils < 2.0.0', ], namespace_packages = [