From 97f51be8cb8b94bea0bc826e122be05a331f63d1 Mon Sep 17 00:00:00 2001 From: Hanno Schlichting Date: Sat, 18 Jul 2009 13:32:08 +0200 Subject: Added a modified bootstrap.py for zc.buildout --HG-- branch : distribute extra : rebase_source : 3c34b6036cbc46315207096f144e99a5eb677627 --- bootstrap.py | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 bootstrap.py (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py new file mode 100644 index 00000000..26bc6922 --- /dev/null +++ b/bootstrap.py @@ -0,0 +1,90 @@ +############################################################################## +# +# Copyright (c) 2006 Zope Corporation and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +"""Bootstrap a buildout-based project + +Simply run this script in a directory containing a buildout.cfg. +The script accepts buildout command-line options, so you can +use the -c option to specify an alternate configuration file. + +$Id: bootstrap.py 101222 2009-06-22 14:05:44Z jim $ +""" + +import os, shutil, sys, tempfile, urllib2 + +tmpeggs = tempfile.mkdtemp() + +is_jython = sys.platform.startswith('java') + +try: + import pkg_resources +except ImportError: + ez = {} + # CHANGED: The following was adjusted to use the distribute ez_setup.py + # instead of the regular setuptools one. + # + # exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' + # ).read() in ez + exec urllib2.urlopen( + 'http://cdn.bitbucket.org/tarek/distribute/downloads/ez_setup.py' + ).read() in ez + ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) + + import pkg_resources + +if sys.platform == 'win32': + def quote(c): + if ' ' in c: + return '"%s"' % c # work around spawn lamosity on windows + else: + return c +else: + def quote (c): + return c + +cmd = 'from setuptools.command.easy_install import main; main()' +ws = pkg_resources.working_set + +if len(sys.argv) > 2 and sys.argv[1] == '--version': + VERSION = '==%s' % sys.argv[2] + args = sys.argv[3:] + ['bootstrap'] +else: + VERSION = '' + args = sys.argv[1:] + ['bootstrap'] + +if is_jython: + import subprocess + + assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', + quote(tmpeggs), 'zc.buildout' + VERSION], + env=dict(os.environ, + PYTHONPATH= + ws.find(pkg_resources.Requirement.parse('setuptools')).location + ), + ).wait() == 0 + +else: + assert os.spawnle( + os.P_WAIT, sys.executable, quote (sys.executable), + '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION, + dict(os.environ, + PYTHONPATH= + ws.find(pkg_resources.Requirement.parse('setuptools')).location + ), + ) == 0 + +ws.add_entry(tmpeggs) +ws.require('zc.buildout' + VERSION) +import zc.buildout.buildout +zc.buildout.buildout.main(args) +shutil.rmtree(tmpeggs) -- cgit v1.2.1 From 96cecd18557e1cf13b9307955019b1091d6a9e30 Mon Sep 17 00:00:00 2001 From: tarek Date: Wed, 22 Jul 2009 11:50:10 +0200 Subject: not needed --HG-- branch : distribute extra : rebase_source : 4d3870896bbf98df5ebd20e172ca0a355dad918c --- bootstrap.py | 90 ------------------------------------------------------------ 1 file changed, 90 deletions(-) delete mode 100644 bootstrap.py (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py deleted file mode 100644 index 26bc6922..00000000 --- a/bootstrap.py +++ /dev/null @@ -1,90 +0,0 @@ -############################################################################## -# -# Copyright (c) 2006 Zope Corporation and Contributors. -# All Rights Reserved. -# -# This software is subject to the provisions of the Zope Public License, -# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. -# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED -# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS -# FOR A PARTICULAR PURPOSE. -# -############################################################################## -"""Bootstrap a buildout-based project - -Simply run this script in a directory containing a buildout.cfg. -The script accepts buildout command-line options, so you can -use the -c option to specify an alternate configuration file. - -$Id: bootstrap.py 101222 2009-06-22 14:05:44Z jim $ -""" - -import os, shutil, sys, tempfile, urllib2 - -tmpeggs = tempfile.mkdtemp() - -is_jython = sys.platform.startswith('java') - -try: - import pkg_resources -except ImportError: - ez = {} - # CHANGED: The following was adjusted to use the distribute ez_setup.py - # instead of the regular setuptools one. - # - # exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' - # ).read() in ez - exec urllib2.urlopen( - 'http://cdn.bitbucket.org/tarek/distribute/downloads/ez_setup.py' - ).read() in ez - ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) - - import pkg_resources - -if sys.platform == 'win32': - def quote(c): - if ' ' in c: - return '"%s"' % c # work around spawn lamosity on windows - else: - return c -else: - def quote (c): - return c - -cmd = 'from setuptools.command.easy_install import main; main()' -ws = pkg_resources.working_set - -if len(sys.argv) > 2 and sys.argv[1] == '--version': - VERSION = '==%s' % sys.argv[2] - args = sys.argv[3:] + ['bootstrap'] -else: - VERSION = '' - args = sys.argv[1:] + ['bootstrap'] - -if is_jython: - import subprocess - - assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', - quote(tmpeggs), 'zc.buildout' + VERSION], - env=dict(os.environ, - PYTHONPATH= - ws.find(pkg_resources.Requirement.parse('setuptools')).location - ), - ).wait() == 0 - -else: - assert os.spawnle( - os.P_WAIT, sys.executable, quote (sys.executable), - '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION, - dict(os.environ, - PYTHONPATH= - ws.find(pkg_resources.Requirement.parse('setuptools')).location - ), - ) == 0 - -ws.add_entry(tmpeggs) -ws.require('zc.buildout' + VERSION) -import zc.buildout.buildout -zc.buildout.buildout.main(args) -shutil.rmtree(tmpeggs) -- cgit v1.2.1 From 25cd11318c2884aa281941d1e0526d9b063a69a6 Mon Sep 17 00:00:00 2001 From: tarek Date: Wed, 22 Jul 2009 17:06:50 +0200 Subject: using boostrap.py name for ez_setup.py because that is what it is --HG-- branch : distribute extra : rebase_source : 2398b9d16b2cda1f2c20c6eff792f49fb59c8cbd --- bootstrap.py | 286 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 bootstrap.py (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py new file mode 100644 index 00000000..a069c95c --- /dev/null +++ b/bootstrap.py @@ -0,0 +1,286 @@ +#!python +"""Bootstrap distribute installation + +If you want to use setuptools in your package's setup.py, just include this +file in the same directory with it, and add this to the top of your setup.py:: + + from ez_setup import use_setuptools + use_setuptools() + +If you want to require a specific version of setuptools, set a download +mirror, or use an alternate download directory, you can do so by supplying +the appropriate options to ``use_setuptools()``. + +This file can also be run as a script to install or upgrade setuptools. +""" +import sys +import os +import shutil +import time + +is_jython = sys.platform.startswith('java') +if is_jython: + import subprocess + +try: + from hashlib import md5 +except ImportError: + from md5 import md5 + +DEFAULT_VERSION = "0.6" +#DEFAULT_URL = "http://pypi.python.org/packages/%s/d/distribute/" % sys.version[:3] +DEFAULT_URL = "http://bitbucket.org/tarek/distribute/downloads/" + +md5_data = { + 'distribute-0.6-py2.3.egg': '2bf26bffe3d8c910de396d45c0f0a24f', + 'distribute-0.6-py2.4.egg': 'c01b1355a5f48344c1c78149f59f68a6', + 'distribute-0.6-py2.5.egg': '2ac319d801bce820a370647916eec84c', + 'distribute-0.6-py2.6.egg': 'fa7906f9caa2c1f0a56daf486bab1583', +} + +def _validate_md5(egg_name, data): + if egg_name in md5_data: + digest = md5(data).hexdigest() + if digest != md5_data[egg_name]: + print >>sys.stderr, ( + "md5 validation of %s failed! (Possible download problem?)" + % egg_name + ) + sys.exit(2) + return data + +def use_setuptools( + version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, + download_delay=15 +): + """Automatically find/download setuptools and make it available on sys.path + + `version` should be a valid setuptools version number that is available + as an egg for download under the `download_base` URL (which should end with + a '/'). `to_dir` is the directory where setuptools will be downloaded, if + it is not already available. If `download_delay` is specified, it should + be the number of seconds that will be paused before initiating a download, + should one be required. If an older version of setuptools is installed, + this routine will print a message to ``sys.stderr`` and raise SystemExit in + an attempt to abort the calling script. + """ + was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules + def do_download(): + egg = download_setuptools(version, download_base, to_dir, download_delay) + sys.path.insert(0, egg) + import setuptools; setuptools.bootstrap_install_from = egg + try: + import pkg_resources + if not hasattr(pkg_resources, '_distribute'): + raise ImportError + except ImportError: + return do_download() + try: + pkg_resources.require("distribute>="+version); return + except pkg_resources.VersionConflict, e: + if was_imported: + print >>sys.stderr, ( + "The required version of distribute (>=%s) is not available, and\n" + "can't be installed while this script is running. Please install\n" + " a more recent version first, using 'easy_install -U distribute'." + "\n\n(Currently using %r)" + ) % (version, e.args[0]) + sys.exit(2) + else: + del pkg_resources, sys.modules['pkg_resources'] # reload ok + return do_download() + except pkg_resources.DistributionNotFound: + return do_download() + +def download_setuptools( + version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, + delay = 15 +): + """Download distribute from a specified location and return its filename + + `version` should be a valid distribute version number that is available + as an egg for download under the `download_base` URL (which should end + with a '/'). `to_dir` is the directory where the egg will be downloaded. + `delay` is the number of seconds to pause before an actual download attempt. + """ + import urllib2, shutil + egg_name = "distribute-%s-py%s.egg" % (version,sys.version[:3]) + url = download_base + egg_name + saveto = os.path.join(to_dir, egg_name) + src = dst = None + if not os.path.exists(saveto): # Avoid repeated downloads + try: + from distutils import log + if delay: + log.warn(""" +--------------------------------------------------------------------------- +This script requires distribute version %s to run (even to display +help). I will attempt to download it for you (from +%s), but +you may need to enable firewall access for this script first. +I will start the download in %d seconds. + +(Note: if this machine does not have network access, please obtain the file + + %s + +and place it in this directory before rerunning this script.) +---------------------------------------------------------------------------""", + version, download_base, delay, url + ); from time import sleep; sleep(delay) + log.warn("Downloading %s", url) + src = urllib2.urlopen(url) + # Read/write all in one block, so we don't create a corrupt file + # if the download is interrupted. + data = _validate_md5(egg_name, src.read()) + dst = open(saveto,"wb"); dst.write(data) + finally: + if src: src.close() + if dst: dst.close() + return os.path.realpath(saveto) + + +SETUPTOOLS_PKG_INFO = """\ +Metadata-Version: 1.0 +Name: setuptools +Version: 0.6c9 +Summary: xxxx +Home-page: xxx +Author: xxx +Author-email: xxx +License: xxx +Description: xxx +""" + +def fake_setuptools(): + from distutils import log + log.warn('Scanning installed packages') + try: + import pkg_resources + except ImportError: + # we're cool + log.warn('Setuptools or Distribute does not seem to be installed.') + return + ws = pkg_resources.working_set + setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools')) + if setuptools_dist is None: + log.warn('No setuptools distribution found') + return + + # detecting if it was already faked + setuptools_location = setuptools_dist.location + log.warn('Setuptools installation detected at %s' % setuptools_location) + pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') + if os.path.exists(pkg_info): + content = open(pkg_info).read() + if SETUPTOOLS_PKG_INFO == content: + # already patched + log.warn('Already patched.') + return + + log.warn('Patching...') + # let's create a fake egg replacing setuptools one + os.rename(setuptools_location, setuptools_location+'.OLD.%s' % time.time()) + os.mkdir(setuptools_location) + os.mkdir(os.path.join(setuptools_location, 'EGG-INFO')) + pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') + f = open(pkg_info, 'w') + try: + f.write(SETUPTOOLS_PKG_INFO) + finally: + f.close() + log.warn('Patched done.') + log.warn('Relaunching...') + # we have to relaunch the process + args = [sys.executable] + sys.argv + if is_jython: + sys.exit(subprocess.Popen([sys.executable] + args).wait()) + else: + sys.exit(os.spawnv(os.P_WAIT, sys.executable, args)) + +def main(argv, version=DEFAULT_VERSION): + """Install or upgrade setuptools and EasyInstall""" + + # let's deactivate any existing setuptools installation first + fake_setuptools() + + try: + import setuptools + # we need to check if the installed setuptools + # is from Distribute or from setuptools + if not hasattr(setuptools, '_distribute'): + # now we are ready to install distribute + raise ImportError + except ImportError: + egg = None + try: + egg = download_setuptools(version, delay=0) + sys.path.insert(0, egg) + from setuptools.command import easy_install + return easy_install.main(list(argv)+['-v']+[egg]) + finally: + if egg and os.path.exists(egg): + os.unlink(egg) + else: + 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) + + req = "distribute>="+version + import pkg_resources + try: + pkg_resources.require(req) + except pkg_resources.VersionConflict: + try: + from setuptools.command.easy_install import main + except ImportError: + from easy_install import main + main(list(argv)+[download_setuptools(delay=0)]) + sys.exit(0) # try to force an exit + else: + if argv: + from setuptools.command.easy_install import main + main(argv) + else: + print "distribute version",version,"or greater has been installed." + print '(Run "ez_setup.py -U distribute" to reinstall or upgrade.)' + +def update_md5(filenames): + """Update our built-in md5 registry""" + + import re + + for name in filenames: + base = os.path.basename(name) + f = open(name,'rb') + md5_data[base] = md5(f.read()).hexdigest() + f.close() + + data = [" %r: %r,\n" % it for it in md5_data.items()] + data.sort() + repl = "".join(data) + + import inspect + srcfile = inspect.getsourcefile(sys.modules[__name__]) + f = open(srcfile, 'rb'); src = f.read(); f.close() + + match = re.search("\nmd5_data = {\n([^}]+)}", src) + if not match: + print >>sys.stderr, "Internal error!" + sys.exit(2) + + src = src[:match.start(1)] + repl + src[match.end(1):] + f = open(srcfile,'w') + f.write(src) + f.close() + + +if __name__ == '__main__': + if len(sys.argv) > 2 and sys.argv[1] == '--md5update': + update_md5(sys.argv[2:]) + else: + main(sys.argv[1:]) + -- cgit v1.2.1 From bcac8b8034b777335ee4ff5ab185233148e47deb Mon Sep 17 00:00:00 2001 From: tarek Date: Thu, 23 Jul 2009 11:31:18 +0200 Subject: more cases from the community --HG-- branch : distribute extra : rebase_source : c22d0ab3bb68209042a1171654c6e6da180a8213 --- bootstrap.py | 118 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 98 insertions(+), 20 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index a069c95c..b0de9366 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -17,6 +17,8 @@ import sys import os import shutil import time +import fnmatch +from distutils import log is_jython = sys.platform.startswith('java') if is_jython: @@ -152,8 +154,74 @@ License: xxx Description: xxx """ +def _patch_file(path, content): + """Will backup the file then patch it""" + existing_content = open(path).read() + if existing_content == content: + # already patched + log.warn('Already patched.') + return False + log.warn('Patching...') + os.rename(path, path +'.OLD.%s' % time.time()) + f = open(path, 'w') + try: + f.write(content) + finally: + f.close() + return True + +def _same_content(path, content): + return open(path).read() == content + +def _rename_path(path): + new_name = path + '.OLD.%s' % time.time() + log.warn('Renaming %s into %s' % (path, new_name)) + os.rename(path, new_name) + return new_name + +def _remove_flat_installation(placeholder): + if not os.path.isdir(placeholder): + log.warn('Unkown installation') + return False + found = False + for file in os.listdir(placeholder): + if fnmatch.fnmatch(file, 'setuptools*.egg-info'): + found = True + break + if not found: + log.warn('Could not locate setuptools*.egg-info') + else: + log.warn('Removing elements out of the way...') + pkg_info = os.path.join(placeholder, file) + if os.path.isdir(pkg_info): + _patch_egg_dir(pkg_info) + else: + patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO) + if not patched: + log.warn('%s already patched.' % pkg_info) + + # now let's move the files out of the way + for element in ('setuptools', 'pkg_resources.py', 'site.py'): + element = os.path.join(placeholder, element) + if os.path.exists(element): + _rename_path(element) + else: + log.warn('Could not find the %s element of the ' + 'Setuptools distribution' % element) + return True + +def _patch_egg_dir(path): + _rename_path(path) + os.mkdir(path) + os.mkdir(os.path.join(path, 'EGG-INFO')) + pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') + f = open(pkg_info, 'w') + try: + f.write(SETUPTOOLS_PKG_INFO) + finally: + f.close() + def fake_setuptools(): - from distutils import log log.warn('Scanning installed packages') try: import pkg_resources @@ -166,30 +234,29 @@ def fake_setuptools(): if setuptools_dist is None: log.warn('No setuptools distribution found') return - # detecting if it was already faked setuptools_location = setuptools_dist.location log.warn('Setuptools installation detected at %s' % setuptools_location) - pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if os.path.exists(pkg_info): - content = open(pkg_info).read() - if SETUPTOOLS_PKG_INFO == content: - # already patched + + # let's see if its an egg until this supports non-egg installation + if not setuptools_location.endswith('.egg'): + log.warn('Non-egg installation') + _remove_flat_installation(setuptools_location) + else: + log.warn('Egg installation') + pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') + if (os.path.exists(pkg_info) and + _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return + log.warn('Patching...') + # let's create a fake egg replacing setuptools one + _patch_egg_dir(setuptools_location) - log.warn('Patching...') - # let's create a fake egg replacing setuptools one - os.rename(setuptools_location, setuptools_location+'.OLD.%s' % time.time()) - os.mkdir(setuptools_location) - os.mkdir(os.path.join(setuptools_location, 'EGG-INFO')) - pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - f = open(pkg_info, 'w') - try: - f.write(SETUPTOOLS_PKG_INFO) - finally: - f.close() log.warn('Patched done.') + _relaunch() + +def _relaunch(): log.warn('Relaunching...') # we have to relaunch the process args = [sys.executable] + sys.argv @@ -200,10 +267,8 @@ def fake_setuptools(): def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" - # let's deactivate any existing setuptools installation first fake_setuptools() - try: import setuptools # we need to check if the installed setuptools @@ -216,6 +281,19 @@ def main(argv, version=DEFAULT_VERSION): try: egg = download_setuptools(version, delay=0) sys.path.insert(0, egg) + import setuptools + if not hasattr(setuptools, '_distribute'): + placeholder = os.path.split(os.path.dirname(setuptools.__file__))[0] + res = _remove_flat_installation(placeholder) + if res: + _relaunch() + print >> sys.stderr, ( + "The patch didn't work, Setuptools is still active.\n" + "Possible reason: your have a system-wide setuptools installed " + "and you are in a virtualenv.\n" + "If you are inside a virtualenv, make sure you used the --no-site-packages option" + ) + sys.exit(2) from setuptools.command import easy_install return easy_install.main(list(argv)+['-v']+[egg]) finally: -- cgit v1.2.1 From db1f56a5908aebb6e26f30cefc77f37c39b0e684 Mon Sep 17 00:00:00 2001 From: tarek Date: Thu, 23 Jul 2009 12:24:01 +0200 Subject: fixed a fork bomb when patching non-egg system-wide installation --HG-- branch : distribute extra : rebase_source : 04596d85e574ecdc4eac518efc1743af724ff129 --- bootstrap.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index b0de9366..9908429b 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -194,12 +194,13 @@ def _remove_flat_installation(placeholder): log.warn('Removing elements out of the way...') pkg_info = os.path.join(placeholder, file) if os.path.isdir(pkg_info): - _patch_egg_dir(pkg_info) + patched = _patch_egg_dir(pkg_info) else: patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO) - if not patched: - log.warn('%s already patched.' % pkg_info) + if not patched: + log.warn('%s already patched.' % pkg_info) + return False # now let's move the files out of the way for element in ('setuptools', 'pkg_resources.py', 'site.py'): element = os.path.join(placeholder, element) @@ -211,6 +212,12 @@ def _remove_flat_installation(placeholder): return True def _patch_egg_dir(path): + # let's check if it's already patched + pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') + if os.path.exists(pkg_info): + if _same_content(pkg_info, SETUPTOOLS_PKG_INFO): + log.warn('%s already patched.' % pkg_info) + return False _rename_path(path) os.mkdir(path) os.mkdir(os.path.join(path, 'EGG-INFO')) @@ -220,6 +227,7 @@ def _patch_egg_dir(path): f.write(SETUPTOOLS_PKG_INFO) finally: f.close() + return True def fake_setuptools(): log.warn('Scanning installed packages') @@ -241,7 +249,9 @@ def fake_setuptools(): # let's see if its an egg until this supports non-egg installation if not setuptools_location.endswith('.egg'): log.warn('Non-egg installation') - _remove_flat_installation(setuptools_location) + res = _remove_flat_installation(setuptools_location) + if not res: + return else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') @@ -251,8 +261,9 @@ def fake_setuptools(): return log.warn('Patching...') # let's create a fake egg replacing setuptools one - _patch_egg_dir(setuptools_location) - + res = _patch_egg_dir(setuptools_location) + if not res: + return log.warn('Patched done.') _relaunch() -- cgit v1.2.1 From b39058a69286b47b7ec63b1be4d50c225f1d30d1 Mon Sep 17 00:00:00 2001 From: tarek Date: Thu, 23 Jul 2009 12:41:43 +0200 Subject: shorcut to avoid unecessary work when located in a non-isolated environment --HG-- branch : distribute extra : rebase_source : 6b093a48e2647923cf36d1dd7ea74def0a961dc6 --- bootstrap.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 9908429b..40505c55 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -181,7 +181,7 @@ def _rename_path(path): def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): - log.warn('Unkown installation') + log.warn('Unkown installation at %s' % placeholder) return False found = False for file in os.listdir(placeholder): @@ -295,9 +295,10 @@ def main(argv, version=DEFAULT_VERSION): import setuptools if not hasattr(setuptools, '_distribute'): placeholder = os.path.split(os.path.dirname(setuptools.__file__))[0] - res = _remove_flat_installation(placeholder) - if res: - _relaunch() + if not placeholder.endswith('.egg'): + res = _remove_flat_installation(placeholder) + if res: + _relaunch() print >> sys.stderr, ( "The patch didn't work, Setuptools is still active.\n" "Possible reason: your have a system-wide setuptools installed " -- cgit v1.2.1 From 1ddd4356e545a49a1345bb02d62b19478805c161 Mon Sep 17 00:00:00 2001 From: tarek Date: Thu, 23 Jul 2009 14:10:00 +0200 Subject: rebuilt the eggs --HG-- branch : distribute extra : rebase_source : c702a73b8784cde5a997feff3d8544ee0aeb9e60 --- bootstrap.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 40505c55..abb73c97 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -34,10 +34,10 @@ DEFAULT_VERSION = "0.6" DEFAULT_URL = "http://bitbucket.org/tarek/distribute/downloads/" md5_data = { - 'distribute-0.6-py2.3.egg': '2bf26bffe3d8c910de396d45c0f0a24f', - 'distribute-0.6-py2.4.egg': 'c01b1355a5f48344c1c78149f59f68a6', - 'distribute-0.6-py2.5.egg': '2ac319d801bce820a370647916eec84c', - 'distribute-0.6-py2.6.egg': 'fa7906f9caa2c1f0a56daf486bab1583', + 'distribute-0.6-py2.3.egg': '83789f9a3b2f32c7088065f6fd3de930', + 'distribute-0.6-py2.4.egg': '8d47e28f76d4b94de1568abed1ad585d', + 'distribute-0.6-py2.5.egg': 'f4295ea6b57b67c30fc223c5fef229d2', + 'distribute-0.6-py2.6.egg': 'c0d34cbce8cd509c33a788f4a5611466', } def _validate_md5(egg_name, data): -- cgit v1.2.1 From 9cca2a8d2e6c815a7a0ae31a14dc8d879f78b2e9 Mon Sep 17 00:00:00 2001 From: tarek Date: Thu, 23 Jul 2009 14:38:31 +0200 Subject: fixed the forbidden access problem --HG-- branch : distribute extra : rebase_source : 4638763f686895225618238abb4f55786a205692 --- bootstrap.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index abb73c97..a861c584 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -19,6 +19,7 @@ import shutil import time import fnmatch from distutils import log +from distutils.errors import DistutilsError is_jython = sys.platform.startswith('java') if is_jython: @@ -31,7 +32,7 @@ except ImportError: DEFAULT_VERSION = "0.6" #DEFAULT_URL = "http://pypi.python.org/packages/%s/d/distribute/" % sys.version[:3] -DEFAULT_URL = "http://bitbucket.org/tarek/distribute/downloads/" +DEFAULT_URL = "http://nightly.ziade.org/" md5_data = { 'distribute-0.6-py2.3.egg': '83789f9a3b2f32c7088065f6fd3de930', @@ -307,7 +308,10 @@ def main(argv, version=DEFAULT_VERSION): ) sys.exit(2) from setuptools.command import easy_install - return easy_install.main(list(argv)+['-v']+[egg]) + try: + return easy_install.main(list(argv)+['-v']+[egg]) + except DistutilsError: + return sys.exit(2) finally: if egg and os.path.exists(egg): os.unlink(egg) -- cgit v1.2.1 From 8d37ba24ed17b6531c86c42e22d178e1e50a22a2 Mon Sep 17 00:00:00 2001 From: tarek Date: Thu, 23 Jul 2009 15:24:40 +0200 Subject: fixed #24: the jython calls now works --HG-- branch : distribute extra : rebase_source : 490026cb4cb661428ab2ca71697664e4cba22909 --- bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index a861c584..e8a058a6 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -273,7 +273,7 @@ def _relaunch(): # we have to relaunch the process args = [sys.executable] + sys.argv if is_jython: - sys.exit(subprocess.Popen([sys.executable] + args).wait()) + sys.exit(subprocess.call(args)) else: sys.exit(os.spawnv(os.P_WAIT, sys.executable, args)) -- cgit v1.2.1 From b934c406ef9371ad36a23e608dcd752b8c311946 Mon Sep 17 00:00:00 2001 From: "tarek@MacZiade-2.local" Date: Tue, 4 Aug 2009 01:51:24 +0200 Subject: added a post install function that ensures setuptools is faked even if not previously present --HG-- branch : distribute extra : rebase_source : 3254ab2ca1f771dd24a6d93a28ca87ca375fe65b --- bootstrap.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index e8a058a6..614f4983 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -212,6 +212,32 @@ def _remove_flat_installation(placeholder): 'Setuptools distribution' % element) return True +def after_install(dist): + log.warn('After install bootstrap.') + placeholder = dist.get_command_obj('install').install_purelib + if not os.path.exists(placeholder): + log.warn('Could not find the install location') + return + pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) + setuptools_file = 'setuptools-0.6c9-py%s.egg' % pyver + pkg_info = os.path.join(placeholder, setuptools_file) + if os.path.exists(pkg_info): + log.warn('%s already exists' % pkg_info) + return + log.warn('Creating %s' % pkg_info) + f = open(pkg_info, 'w') + try: + f.write(SETUPTOOLS_PKG_INFO) + finally: + f.close() + pth_file = os.path.join(placeholder, 'setuptools.pth') + log.warn('Creating %s' % pth_file) + f = open(pth_file, 'w') + try: + f.write(os.path.join(os.curdir, setuptools_file)) + finally: + f.close() + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -230,6 +256,10 @@ def _patch_egg_dir(path): f.close() return True +def before_install(): + log.warn('Before install bootstrap.') + fake_setuptools() + def fake_setuptools(): log.warn('Scanning installed packages') try: @@ -238,7 +268,7 @@ def fake_setuptools(): # we're cool log.warn('Setuptools or Distribute does not seem to be installed.') return - ws = pkg_resources.working_set + ws = pkg_resources.working_set setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools')) if setuptools_dist is None: log.warn('No setuptools distribution found') @@ -247,7 +277,7 @@ def fake_setuptools(): setuptools_location = setuptools_dist.location log.warn('Setuptools installation detected at %s' % setuptools_location) - # let's see if its an egg until this supports non-egg installation + # let's see if its an egg if not setuptools_location.endswith('.egg'): log.warn('Non-egg installation') res = _remove_flat_installation(setuptools_location) -- cgit v1.2.1 From 897e85aac71a6057ec09d0ff8e93b32665c91979 Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 4 Aug 2009 03:03:50 +0200 Subject: typo --HG-- branch : distribute extra : rebase_source : 7cfffe36c679de9f95b776786e808d04c7e05e4c --- bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 614f4983..53c0a11d 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -219,7 +219,7 @@ def after_install(dist): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-0.6c9-py%s.egg' % pyver + setuptools_file = 'setuptools-0.6c9-py%s.egg-info' % pyver pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists' % pkg_info) -- cgit v1.2.1 From a227478f733dc6d7013c1985c36c83639f4392ce Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 4 Aug 2009 03:16:37 +0200 Subject: now calling after_install in bootstrap.main too --HG-- branch : distribute extra : rebase_source : 5ed71a412016a97c699ebf16d92d3e476cb5c3f0 --- bootstrap.py | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 53c0a11d..27b49c78 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -307,6 +307,22 @@ def _relaunch(): else: sys.exit(os.spawnv(os.P_WAIT, sys.executable, args)) +def _easy_install(argv, egg=None): + from setuptools import setup + from setuptools.dist import Distribution + import distutils.core + if egg is not None: + setup_args = list(argv) + ['-v'] + [egg] + else: + setup_args = list(argv) + try: + return setup(script_args = ['-q','easy_install', + '-v'] + setup_args, + script_name = sys.argv[0] or 'easy_install', + distclass=Distribution) + except DistutilsError: + return sys.exit(2) + def main(argv, version=DEFAULT_VERSION): """Install or upgrade setuptools and EasyInstall""" # let's deactivate any existing setuptools installation first @@ -337,11 +353,14 @@ def main(argv, version=DEFAULT_VERSION): "If you are inside a virtualenv, make sure you used the --no-site-packages option" ) sys.exit(2) - from setuptools.command import easy_install - try: - return easy_install.main(list(argv)+['-v']+[egg]) - except DistutilsError: - return sys.exit(2) + dist = _easy_install(argv, egg) + after_install(dist) + return + #from setuptools.command import easy_install + #try: + # return easy_install.main(list(argv)+['-v']+[egg]) + #except DistutilsError: + # return sys.exit(2) finally: if egg and os.path.exists(egg): os.unlink(egg) @@ -359,15 +378,17 @@ def main(argv, version=DEFAULT_VERSION): pkg_resources.require(req) except pkg_resources.VersionConflict: try: - from setuptools.command.easy_install import main + _easy_install(argv, [download_setuptools(delay=0)]) + #from setuptools.command.easy_install import main except ImportError: from easy_install import main - main(list(argv)+[download_setuptools(delay=0)]) + main(list(argv)+[download_setuptools(delay=0)]) sys.exit(0) # try to force an exit else: if argv: - from setuptools.command.easy_install import main - main(argv) + _easy_install(argv) + #from setuptools.command.easy_install import main + #main(argv) else: print "distribute version",version,"or greater has been installed." print '(Run "ez_setup.py -U distribute" to reinstall or upgrade.)' -- cgit v1.2.1 From 9fe6021cb2c6da3d0af28da0311033ce008765ad Mon Sep 17 00:00:00 2001 From: tarek Date: Tue, 4 Aug 2009 11:02:01 +0200 Subject: renamed bootstrap.py to bootstraping.py so it differs from zc.buildout filename --HG-- branch : distribute extra : rebase_source : b784247763e9f8814d70ba9ffcf07ceab02a3ba4 --- bootstrap.py | 431 ----------------------------------------------------------- 1 file changed, 431 deletions(-) delete mode 100644 bootstrap.py (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py deleted file mode 100644 index 27b49c78..00000000 --- a/bootstrap.py +++ /dev/null @@ -1,431 +0,0 @@ -#!python -"""Bootstrap distribute installation - -If you want to use setuptools in your package's setup.py, just include this -file in the same directory with it, and add this to the top of your setup.py:: - - from ez_setup import use_setuptools - use_setuptools() - -If you want to require a specific version of setuptools, set a download -mirror, or use an alternate download directory, you can do so by supplying -the appropriate options to ``use_setuptools()``. - -This file can also be run as a script to install or upgrade setuptools. -""" -import sys -import os -import shutil -import time -import fnmatch -from distutils import log -from distutils.errors import DistutilsError - -is_jython = sys.platform.startswith('java') -if is_jython: - import subprocess - -try: - from hashlib import md5 -except ImportError: - from md5 import md5 - -DEFAULT_VERSION = "0.6" -#DEFAULT_URL = "http://pypi.python.org/packages/%s/d/distribute/" % sys.version[:3] -DEFAULT_URL = "http://nightly.ziade.org/" - -md5_data = { - 'distribute-0.6-py2.3.egg': '83789f9a3b2f32c7088065f6fd3de930', - 'distribute-0.6-py2.4.egg': '8d47e28f76d4b94de1568abed1ad585d', - 'distribute-0.6-py2.5.egg': 'f4295ea6b57b67c30fc223c5fef229d2', - 'distribute-0.6-py2.6.egg': 'c0d34cbce8cd509c33a788f4a5611466', -} - -def _validate_md5(egg_name, data): - if egg_name in md5_data: - digest = md5(data).hexdigest() - if digest != md5_data[egg_name]: - print >>sys.stderr, ( - "md5 validation of %s failed! (Possible download problem?)" - % egg_name - ) - sys.exit(2) - return data - -def use_setuptools( - version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, - download_delay=15 -): - """Automatically find/download setuptools and make it available on sys.path - - `version` should be a valid setuptools version number that is available - as an egg for download under the `download_base` URL (which should end with - a '/'). `to_dir` is the directory where setuptools will be downloaded, if - it is not already available. If `download_delay` is specified, it should - be the number of seconds that will be paused before initiating a download, - should one be required. If an older version of setuptools is installed, - this routine will print a message to ``sys.stderr`` and raise SystemExit in - an attempt to abort the calling script. - """ - was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules - def do_download(): - egg = download_setuptools(version, download_base, to_dir, download_delay) - sys.path.insert(0, egg) - import setuptools; setuptools.bootstrap_install_from = egg - try: - import pkg_resources - if not hasattr(pkg_resources, '_distribute'): - raise ImportError - except ImportError: - return do_download() - try: - pkg_resources.require("distribute>="+version); return - except pkg_resources.VersionConflict, e: - if was_imported: - print >>sys.stderr, ( - "The required version of distribute (>=%s) is not available, and\n" - "can't be installed while this script is running. Please install\n" - " a more recent version first, using 'easy_install -U distribute'." - "\n\n(Currently using %r)" - ) % (version, e.args[0]) - sys.exit(2) - else: - del pkg_resources, sys.modules['pkg_resources'] # reload ok - return do_download() - except pkg_resources.DistributionNotFound: - return do_download() - -def download_setuptools( - version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, - delay = 15 -): - """Download distribute from a specified location and return its filename - - `version` should be a valid distribute version number that is available - as an egg for download under the `download_base` URL (which should end - with a '/'). `to_dir` is the directory where the egg will be downloaded. - `delay` is the number of seconds to pause before an actual download attempt. - """ - import urllib2, shutil - egg_name = "distribute-%s-py%s.egg" % (version,sys.version[:3]) - url = download_base + egg_name - saveto = os.path.join(to_dir, egg_name) - src = dst = None - if not os.path.exists(saveto): # Avoid repeated downloads - try: - from distutils import log - if delay: - log.warn(""" ---------------------------------------------------------------------------- -This script requires distribute version %s to run (even to display -help). I will attempt to download it for you (from -%s), but -you may need to enable firewall access for this script first. -I will start the download in %d seconds. - -(Note: if this machine does not have network access, please obtain the file - - %s - -and place it in this directory before rerunning this script.) ----------------------------------------------------------------------------""", - version, download_base, delay, url - ); from time import sleep; sleep(delay) - log.warn("Downloading %s", url) - src = urllib2.urlopen(url) - # Read/write all in one block, so we don't create a corrupt file - # if the download is interrupted. - data = _validate_md5(egg_name, src.read()) - dst = open(saveto,"wb"); dst.write(data) - finally: - if src: src.close() - if dst: dst.close() - return os.path.realpath(saveto) - - -SETUPTOOLS_PKG_INFO = """\ -Metadata-Version: 1.0 -Name: setuptools -Version: 0.6c9 -Summary: xxxx -Home-page: xxx -Author: xxx -Author-email: xxx -License: xxx -Description: xxx -""" - -def _patch_file(path, content): - """Will backup the file then patch it""" - existing_content = open(path).read() - if existing_content == content: - # already patched - log.warn('Already patched.') - return False - log.warn('Patching...') - os.rename(path, path +'.OLD.%s' % time.time()) - f = open(path, 'w') - try: - f.write(content) - finally: - f.close() - return True - -def _same_content(path, content): - return open(path).read() == content - -def _rename_path(path): - new_name = path + '.OLD.%s' % time.time() - log.warn('Renaming %s into %s' % (path, new_name)) - os.rename(path, new_name) - return new_name - -def _remove_flat_installation(placeholder): - if not os.path.isdir(placeholder): - log.warn('Unkown installation at %s' % placeholder) - return False - found = False - for file in os.listdir(placeholder): - if fnmatch.fnmatch(file, 'setuptools*.egg-info'): - found = True - break - if not found: - log.warn('Could not locate setuptools*.egg-info') - else: - log.warn('Removing elements out of the way...') - pkg_info = os.path.join(placeholder, file) - if os.path.isdir(pkg_info): - patched = _patch_egg_dir(pkg_info) - else: - patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO) - - if not patched: - log.warn('%s already patched.' % pkg_info) - return False - # now let's move the files out of the way - for element in ('setuptools', 'pkg_resources.py', 'site.py'): - element = os.path.join(placeholder, element) - if os.path.exists(element): - _rename_path(element) - else: - log.warn('Could not find the %s element of the ' - 'Setuptools distribution' % element) - return True - -def after_install(dist): - log.warn('After install bootstrap.') - placeholder = dist.get_command_obj('install').install_purelib - if not os.path.exists(placeholder): - log.warn('Could not find the install location') - return - pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-0.6c9-py%s.egg-info' % pyver - pkg_info = os.path.join(placeholder, setuptools_file) - if os.path.exists(pkg_info): - log.warn('%s already exists' % pkg_info) - return - log.warn('Creating %s' % pkg_info) - f = open(pkg_info, 'w') - try: - f.write(SETUPTOOLS_PKG_INFO) - finally: - f.close() - pth_file = os.path.join(placeholder, 'setuptools.pth') - log.warn('Creating %s' % pth_file) - f = open(pth_file, 'w') - try: - f.write(os.path.join(os.curdir, setuptools_file)) - finally: - f.close() - -def _patch_egg_dir(path): - # let's check if it's already patched - pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') - if os.path.exists(pkg_info): - if _same_content(pkg_info, SETUPTOOLS_PKG_INFO): - log.warn('%s already patched.' % pkg_info) - return False - _rename_path(path) - os.mkdir(path) - os.mkdir(os.path.join(path, 'EGG-INFO')) - pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') - f = open(pkg_info, 'w') - try: - f.write(SETUPTOOLS_PKG_INFO) - finally: - f.close() - return True - -def before_install(): - log.warn('Before install bootstrap.') - fake_setuptools() - -def fake_setuptools(): - log.warn('Scanning installed packages') - try: - import pkg_resources - except ImportError: - # we're cool - log.warn('Setuptools or Distribute does not seem to be installed.') - return - ws = pkg_resources.working_set - setuptools_dist = ws.find(pkg_resources.Requirement.parse('setuptools')) - if setuptools_dist is None: - log.warn('No setuptools distribution found') - return - # detecting if it was already faked - setuptools_location = setuptools_dist.location - log.warn('Setuptools installation detected at %s' % setuptools_location) - - # let's see if its an egg - if not setuptools_location.endswith('.egg'): - log.warn('Non-egg installation') - res = _remove_flat_installation(setuptools_location) - if not res: - return - else: - log.warn('Egg installation') - pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): - log.warn('Already patched.') - return - log.warn('Patching...') - # let's create a fake egg replacing setuptools one - res = _patch_egg_dir(setuptools_location) - if not res: - return - log.warn('Patched done.') - _relaunch() - -def _relaunch(): - log.warn('Relaunching...') - # we have to relaunch the process - args = [sys.executable] + sys.argv - if is_jython: - sys.exit(subprocess.call(args)) - else: - sys.exit(os.spawnv(os.P_WAIT, sys.executable, args)) - -def _easy_install(argv, egg=None): - from setuptools import setup - from setuptools.dist import Distribution - import distutils.core - if egg is not None: - setup_args = list(argv) + ['-v'] + [egg] - else: - setup_args = list(argv) - try: - return setup(script_args = ['-q','easy_install', - '-v'] + setup_args, - script_name = sys.argv[0] or 'easy_install', - distclass=Distribution) - except DistutilsError: - return sys.exit(2) - -def main(argv, version=DEFAULT_VERSION): - """Install or upgrade setuptools and EasyInstall""" - # let's deactivate any existing setuptools installation first - fake_setuptools() - try: - import setuptools - # we need to check if the installed setuptools - # is from Distribute or from setuptools - if not hasattr(setuptools, '_distribute'): - # now we are ready to install distribute - raise ImportError - except ImportError: - egg = None - try: - egg = download_setuptools(version, delay=0) - sys.path.insert(0, egg) - import setuptools - if not hasattr(setuptools, '_distribute'): - placeholder = os.path.split(os.path.dirname(setuptools.__file__))[0] - if not placeholder.endswith('.egg'): - res = _remove_flat_installation(placeholder) - if res: - _relaunch() - print >> sys.stderr, ( - "The patch didn't work, Setuptools is still active.\n" - "Possible reason: your have a system-wide setuptools installed " - "and you are in a virtualenv.\n" - "If you are inside a virtualenv, make sure you used the --no-site-packages option" - ) - sys.exit(2) - dist = _easy_install(argv, egg) - after_install(dist) - return - #from setuptools.command import easy_install - #try: - # return easy_install.main(list(argv)+['-v']+[egg]) - #except DistutilsError: - # return sys.exit(2) - finally: - if egg and os.path.exists(egg): - os.unlink(egg) - else: - 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) - - req = "distribute>="+version - import pkg_resources - try: - pkg_resources.require(req) - except pkg_resources.VersionConflict: - try: - _easy_install(argv, [download_setuptools(delay=0)]) - #from setuptools.command.easy_install import main - except ImportError: - from easy_install import main - main(list(argv)+[download_setuptools(delay=0)]) - sys.exit(0) # try to force an exit - else: - if argv: - _easy_install(argv) - #from setuptools.command.easy_install import main - #main(argv) - else: - print "distribute version",version,"or greater has been installed." - print '(Run "ez_setup.py -U distribute" to reinstall or upgrade.)' - -def update_md5(filenames): - """Update our built-in md5 registry""" - - import re - - for name in filenames: - base = os.path.basename(name) - f = open(name,'rb') - md5_data[base] = md5(f.read()).hexdigest() - f.close() - - data = [" %r: %r,\n" % it for it in md5_data.items()] - data.sort() - repl = "".join(data) - - import inspect - srcfile = inspect.getsourcefile(sys.modules[__name__]) - f = open(srcfile, 'rb'); src = f.read(); f.close() - - match = re.search("\nmd5_data = {\n([^}]+)}", src) - if not match: - print >>sys.stderr, "Internal error!" - sys.exit(2) - - src = src[:match.start(1)] + repl + src[match.end(1):] - f = open(srcfile,'w') - f.write(src) - f.close() - - -if __name__ == '__main__': - if len(sys.argv) > 2 and sys.argv[1] == '--md5update': - update_md5(sys.argv[2:]) - else: - main(sys.argv[1:]) - -- cgit v1.2.1 From 2c923b60ebb68e23de2f6ba64a3ca226204b116c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 25 Oct 2014 19:31:28 -0400 Subject: Adding 'bootstrap.py' for bootstrapping a development environment when setuptools metadata isn't already present. Fixes #278. --- bootstrap.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bootstrap.py (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py new file mode 100644 index 00000000..cbc1ca9d --- /dev/null +++ b/bootstrap.py @@ -0,0 +1,51 @@ +""" +If setuptools is not already installed in the environment, it's not possible +to invoke setuptools' own commands. This routine will bootstrap this local +environment by creating a minimal egg-info directory and then invoking the +egg-info command to flesh out the egg-info directory. +""" + +import os +import sys +import textwrap +import subprocess + + +minimal_egg_info = textwrap.dedent(""" + [distutils.commands] + egg_info = setuptools.command.egg_info:egg_info + + [distutils.setup_keywords] + include_package_data = setuptools.dist:assert_bool + install_requires = setuptools.dist:check_requirements + extras_require = setuptools.dist:check_extras + entry_points = setuptools.dist:check_entry_points + + [egg_info.writers] + dependency_links.txt = setuptools.command.egg_info:overwrite_arg + entry_points.txt = setuptools.command.egg_info:write_entries + requires.txt = setuptools.command.egg_info:write_requirements + """) + +def ensure_egg_info(): + if not os.path.exists('setuptools.egg-info'): + build_egg_info() + + +def build_egg_info(): + """ + Build a minimal egg-info, enough to invoke egg_info + """ + + os.mkdir('setuptools.egg-info') + with open('setuptools.egg-info/entry_points.txt', 'w') as ep: + ep.write(minimal_egg_info) + + +def run_egg_info(): + subprocess.check_call([sys.executable, 'setup.py', 'egg_info']) + + +if __name__ == '__main__': + ensure_egg_info() + run_egg_info() -- cgit v1.2.1 From 07e879f2f26d85bbb5c7437e7b1ff714774b3ed3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 21:49:37 -0500 Subject: Add output to determine if egg-info is being created. --- bootstrap.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index cbc1ca9d..919594f7 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -28,8 +28,10 @@ minimal_egg_info = textwrap.dedent(""" """) def ensure_egg_info(): - if not os.path.exists('setuptools.egg-info'): - build_egg_info() + if os.path.exists('setuptools.egg-info'): + return + print("adding minimal entry_points") + build_egg_info() def build_egg_info(): -- cgit v1.2.1 From 44d61f17fe8c04fc6046fe04a88a076a49ce6c2e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 21:57:30 -0500 Subject: Also print a message here --- bootstrap.py | 1 + 1 file changed, 1 insertion(+) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 919594f7..60a1b88d 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -45,6 +45,7 @@ def build_egg_info(): def run_egg_info(): + print("Regenerating egg_info") subprocess.check_call([sys.executable, 'setup.py', 'egg_info']) -- cgit v1.2.1 From 685922ef03d8357a94624b799824bde61d27a9eb Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 2 Jan 2015 22:02:21 -0500 Subject: Try generating egg_info twice. --- bootstrap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 60a1b88d..70f96258 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -45,8 +45,11 @@ def build_egg_info(): def run_egg_info(): + cmd = [sys.executable, 'setup.py', 'egg_info'] print("Regenerating egg_info") - subprocess.check_call([sys.executable, 'setup.py', 'egg_info']) + subprocess.check_call(cmd) + print("...and again.") + subprocess.check_call(cmd) if __name__ == '__main__': -- cgit v1.2.1 From 6d11e88f938f09ef16db4c6064b6e74acba4db1d Mon Sep 17 00:00:00 2001 From: stepshal Date: Tue, 12 Jul 2016 22:00:43 +0700 Subject: Fix quantity of blank lines after code object. --- bootstrap.py | 1 + 1 file changed, 1 insertion(+) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 70f96258..bf7fb431 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -27,6 +27,7 @@ minimal_egg_info = textwrap.dedent(""" requires.txt = setuptools.command.egg_info:write_requirements """) + def ensure_egg_info(): if os.path.exists('setuptools.egg-info'): return -- cgit v1.2.1 From 31bd37c6ac8de9e8c1bacebc2d8e1215df91eb96 Mon Sep 17 00:00:00 2001 From: stepshal Date: Tue, 18 Oct 2016 20:24:35 +0700 Subject: Fix quantity of blank lines. --- bootstrap.py | 1 - 1 file changed, 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index bf7fb431..c5f470a4 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -10,7 +10,6 @@ import sys import textwrap import subprocess - minimal_egg_info = textwrap.dedent(""" [distutils.commands] egg_info = setuptools.command.egg_info:egg_info -- cgit v1.2.1 From ff371f18f0076bc63da05334f7e551c1cc29e10d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 22:34:28 -0500 Subject: Strip out vendored packages and require them instead. Ref #581. --- bootstrap.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index c5f470a4..761b8dfc 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,6 +5,8 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ +__requires__ = ['packaging', 'six', 'appdirs'] + import os import sys import textwrap -- cgit v1.2.1 From a36dbf75bd6b1283fd3da28c25fd583f20025c36 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 23:12:23 -0500 Subject: In the bootstrap script, generate a requirements.txt file and use it to install the dependencies just in time to make them available long enough to generate the egg info. --- bootstrap.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 761b8dfc..705a8720 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,13 +5,18 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ -__requires__ = ['packaging', 'six', 'appdirs'] - import os +import io +import re +import contextlib +import tempfile +import shutil import sys import textwrap import subprocess +import pip + minimal_egg_info = textwrap.dedent(""" [distutils.commands] egg_info = setuptools.command.egg_info:egg_info @@ -54,6 +59,35 @@ def run_egg_info(): subprocess.check_call(cmd) +def gen_deps(): + with io.open('setup.py', encoding='utf-8') as strm: + text = strm.read() + pattern = r'install_requires=\[(.*?)\]' + match = re.search(pattern, text, flags=re.M|re.DOTALL) + reqs = eval(match.group(1).replace('\n', '')) + with io.open('requirements.txt', 'w', encoding='utf-8') as reqs_file: + reqs_file.write('\n'.join(reqs)) + + +@contextlib.contextmanager +def install_deps(): + "Just in time make the deps available" + gen_deps() + tmpdir = tempfile.mkdtemp() + args = [ + 'install', + '-t', tmpdir, + '-r', 'requirements.txt', + ] + pip.main(args) + os.environ['PYTHONPATH'] = tmpdir + try: + yield tmpdir + finally: + shutil.rmtree(tmpdir) + + if __name__ == '__main__': ensure_egg_info() - run_egg_info() + with install_deps(): + run_egg_info() -- cgit v1.2.1 From 767dcea007cf19b016c33f036f750c87b5876d1f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 23:15:38 -0500 Subject: Use unicode literals --- bootstrap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 705a8720..f7644f12 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,6 +5,8 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ +from __future__ import unicode_literals + import os import io import re @@ -47,7 +49,8 @@ def build_egg_info(): """ os.mkdir('setuptools.egg-info') - with open('setuptools.egg-info/entry_points.txt', 'w') as ep: + filename = 'setuptools.egg-info/entry_points.txt' + with io.open(filename, 'w', encoding='utf-8') as ep: ep.write(minimal_egg_info) -- cgit v1.2.1 From 4481a64e2c905f40afa478ebd5418614f322b9b0 Mon Sep 17 00:00:00 2001 From: Jonathan Helmus Date: Thu, 2 Feb 2017 08:54:37 -0600 Subject: Add --skip-dep-install to boostrap.py script The --skip-dep-install flag skips installation of setuptools dependencies using pip, delegating this responsibility to other tools. This can be used to install setuptools without the need for pip. closes #950 --- bootstrap.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index f7644f12..1a789311 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -7,6 +7,7 @@ egg-info command to flesh out the egg-info directory. from __future__ import unicode_literals +import argparse import os import io import re @@ -17,7 +18,6 @@ import sys import textwrap import subprocess -import pip minimal_egg_info = textwrap.dedent(""" [distutils.commands] @@ -75,6 +75,7 @@ def gen_deps(): @contextlib.contextmanager def install_deps(): "Just in time make the deps available" + import pip gen_deps() tmpdir = tempfile.mkdtemp() args = [ @@ -91,6 +92,15 @@ def install_deps(): if __name__ == '__main__': + parser = argparse.ArgumentParser(description='bootstrap setuptools') + parser.add_argument( + '--skip-dep-install', action='store_true', + help=("Do not attempt to install setuptools dependencies. These " + "should be provided in the environment in another manner.")) + args = parser.parse_args() ensure_egg_info() - with install_deps(): + if args.skip_dep_install: run_egg_info() + else: + with install_deps(): + run_egg_info() -- cgit v1.2.1 From c182abae2af4cb5e12bb8200995a0026de07f146 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 2 Feb 2017 10:50:47 -0500 Subject: Extract main function --- bootstrap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 1a789311..2ca678ff 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -91,7 +91,7 @@ def install_deps(): shutil.rmtree(tmpdir) -if __name__ == '__main__': +def main(): parser = argparse.ArgumentParser(description='bootstrap setuptools') parser.add_argument( '--skip-dep-install', action='store_true', @@ -104,3 +104,6 @@ if __name__ == '__main__': else: with install_deps(): run_egg_info() + + +__name__ == '__main__' and main() -- cgit v1.2.1 From 174e84e0ce297c38aa11f6618c7d0dad7f1a5acf Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 2 Feb 2017 11:01:37 -0500 Subject: In bootstrap, defer installation of dependencies if unneeded. Ref #958. --- bootstrap.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 2ca678ff..ad9b067e 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -7,7 +7,6 @@ egg-info command to flesh out the egg-info directory. from __future__ import unicode_literals -import argparse import os import io import re @@ -92,16 +91,12 @@ def install_deps(): def main(): - parser = argparse.ArgumentParser(description='bootstrap setuptools') - parser.add_argument( - '--skip-dep-install', action='store_true', - help=("Do not attempt to install setuptools dependencies. These " - "should be provided in the environment in another manner.")) - args = parser.parse_args() ensure_egg_info() - if args.skip_dep_install: + try: + # first assume dependencies are present run_egg_info() - else: + except Exception: + # but if that fails, try again with dependencies just in time with install_deps(): run_egg_info() -- cgit v1.2.1 From e65c45538fab94008b8066edd134725be8f9c400 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 2 Feb 2017 11:21:38 -0500 Subject: Always generate the dependencies. --- bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index ad9b067e..ee3b53c8 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -75,7 +75,6 @@ def gen_deps(): def install_deps(): "Just in time make the deps available" import pip - gen_deps() tmpdir = tempfile.mkdtemp() args = [ 'install', @@ -92,6 +91,7 @@ def install_deps(): def main(): ensure_egg_info() + gen_deps() try: # first assume dependencies are present run_egg_info() -- cgit v1.2.1 From 3d0cc355fb5e8012cb8c72f0e25042a5a44f31d6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Feb 2017 11:49:51 -0500 Subject: Revert "Merge pull request #933 from pypa/feature/581-depend-not-bundle" This reverts commit 089cdeb489a0fa94d11b7307b54210ef9aa40511, reversing changes made to aaec654d804cb78dbb6391afff721a63f26a71cd. --- bootstrap.py | 47 ++--------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index ee3b53c8..24d7093c 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,14 +5,7 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ -from __future__ import unicode_literals - import os -import io -import re -import contextlib -import tempfile -import shutil import sys import textwrap import subprocess @@ -48,8 +41,7 @@ def build_egg_info(): """ os.mkdir('setuptools.egg-info') - filename = 'setuptools.egg-info/entry_points.txt' - with io.open(filename, 'w', encoding='utf-8') as ep: + with open('setuptools.egg-info/entry_points.txt', 'w') as ep: ep.write(minimal_egg_info) @@ -61,44 +53,9 @@ def run_egg_info(): subprocess.check_call(cmd) -def gen_deps(): - with io.open('setup.py', encoding='utf-8') as strm: - text = strm.read() - pattern = r'install_requires=\[(.*?)\]' - match = re.search(pattern, text, flags=re.M|re.DOTALL) - reqs = eval(match.group(1).replace('\n', '')) - with io.open('requirements.txt', 'w', encoding='utf-8') as reqs_file: - reqs_file.write('\n'.join(reqs)) - - -@contextlib.contextmanager -def install_deps(): - "Just in time make the deps available" - import pip - tmpdir = tempfile.mkdtemp() - args = [ - 'install', - '-t', tmpdir, - '-r', 'requirements.txt', - ] - pip.main(args) - os.environ['PYTHONPATH'] = tmpdir - try: - yield tmpdir - finally: - shutil.rmtree(tmpdir) - - def main(): ensure_egg_info() - gen_deps() - try: - # first assume dependencies are present - run_egg_info() - except Exception: - # but if that fails, try again with dependencies just in time - with install_deps(): - run_egg_info() + run_egg_info() __name__ == '__main__' and main() -- cgit v1.2.1 From 3b443bc9ca9d7159f57fc232c97a4635ecb4086f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Jun 2017 15:33:40 -0400 Subject: Use io.open when saving entry_points. --- bootstrap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 24d7093c..f3a12c07 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -9,6 +9,7 @@ import os import sys import textwrap import subprocess +import io minimal_egg_info = textwrap.dedent(""" @@ -41,7 +42,7 @@ def build_egg_info(): """ os.mkdir('setuptools.egg-info') - with open('setuptools.egg-info/entry_points.txt', 'w') as ep: + with io.open('setuptools.egg-info/entry_points.txt', 'w') as ep: ep.write(minimal_egg_info) -- cgit v1.2.1 From dd622e26da86651bf1f0506452c2c55eb1eb8f4d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 13 Jul 2017 14:23:07 -0400 Subject: Use unicode_literals in bootstrap script --- bootstrap.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index f3a12c07..8c7d7fc3 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,6 +5,8 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ +from __future__ import unicode_literals + import os import sys import textwrap -- cgit v1.2.1 From d09dd5ff998887536e3e898ec7c007053d96e0aa Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Jan 2020 11:29:30 -0500 Subject: Include PKG-INFO in minimal egg-info so that metadata doesn't need to be generated twice during bootstrap. --- bootstrap.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 8c7d7fc3..077bf690 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -25,6 +25,7 @@ minimal_egg_info = textwrap.dedent(""" entry_points = setuptools.dist:check_entry_points [egg_info.writers] + PKG-INFO = setuptools.command.egg_info:write_pkg_info dependency_links.txt = setuptools.command.egg_info:overwrite_arg entry_points.txt = setuptools.command.egg_info:write_entries requires.txt = setuptools.command.egg_info:write_requirements @@ -52,8 +53,6 @@ def run_egg_info(): cmd = [sys.executable, 'setup.py', 'egg_info'] print("Regenerating egg_info") subprocess.check_call(cmd) - print("...and again.") - subprocess.check_call(cmd) def main(): -- cgit v1.2.1 From 7f6394863dc096b9f31e71a5843acbd836ff8d6c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Jan 2020 11:43:44 -0500 Subject: Only run 'egg_info' when bootstrapping was required. --- bootstrap.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 077bf690..8fa9e4b5 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -36,10 +36,11 @@ def ensure_egg_info(): if os.path.exists('setuptools.egg-info'): return print("adding minimal entry_points") - build_egg_info() + add_minimal_info() + run_egg_info() -def build_egg_info(): +def add_minimal_info(): """ Build a minimal egg-info, enough to invoke egg_info """ @@ -55,9 +56,4 @@ def run_egg_info(): subprocess.check_call(cmd) -def main(): - ensure_egg_info() - run_egg_info() - - -__name__ == '__main__' and main() +__name__ == '__main__' and ensure_egg_info() -- cgit v1.2.1 From fb7ab81a3d080422687bad71f9ae9d36eeefbee2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 16 Aug 2020 00:29:24 -0400 Subject: Remove Python 2 compatibility --- bootstrap.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py index 8fa9e4b5..118671f6 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -5,8 +5,6 @@ environment by creating a minimal egg-info directory and then invoking the egg-info command to flesh out the egg-info directory. """ -from __future__ import unicode_literals - import os import sys import textwrap -- cgit v1.2.1 From 183a306ef87fd15df27dc4327182a944033ea3a0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 19 Jan 2021 20:37:26 -0500 Subject: Remove bootstrap and tox-pip and instead rely on pep517. --- bootstrap.py | 57 --------------------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 bootstrap.py (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py deleted file mode 100644 index 118671f6..00000000 --- a/bootstrap.py +++ /dev/null @@ -1,57 +0,0 @@ -""" -If setuptools is not already installed in the environment, it's not possible -to invoke setuptools' own commands. This routine will bootstrap this local -environment by creating a minimal egg-info directory and then invoking the -egg-info command to flesh out the egg-info directory. -""" - -import os -import sys -import textwrap -import subprocess -import io - - -minimal_egg_info = textwrap.dedent(""" - [distutils.commands] - egg_info = setuptools.command.egg_info:egg_info - - [distutils.setup_keywords] - include_package_data = setuptools.dist:assert_bool - install_requires = setuptools.dist:check_requirements - extras_require = setuptools.dist:check_extras - entry_points = setuptools.dist:check_entry_points - - [egg_info.writers] - PKG-INFO = setuptools.command.egg_info:write_pkg_info - dependency_links.txt = setuptools.command.egg_info:overwrite_arg - entry_points.txt = setuptools.command.egg_info:write_entries - requires.txt = setuptools.command.egg_info:write_requirements - """) - - -def ensure_egg_info(): - if os.path.exists('setuptools.egg-info'): - return - print("adding minimal entry_points") - add_minimal_info() - run_egg_info() - - -def add_minimal_info(): - """ - Build a minimal egg-info, enough to invoke egg_info - """ - - os.mkdir('setuptools.egg-info') - with io.open('setuptools.egg-info/entry_points.txt', 'w') as ep: - ep.write(minimal_egg_info) - - -def run_egg_info(): - cmd = [sys.executable, 'setup.py', 'egg_info'] - print("Regenerating egg_info") - subprocess.check_call(cmd) - - -__name__ == '__main__' and ensure_egg_info() -- cgit v1.2.1 From e3e7ff854038788d56d6d7f6624357b81341e876 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 23 Jan 2021 14:20:57 -0500 Subject: For compatibility, add a bootstrap script with a warning. --- bootstrap.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 bootstrap.py (limited to 'bootstrap.py') diff --git a/bootstrap.py b/bootstrap.py new file mode 100644 index 00000000..229b9965 --- /dev/null +++ b/bootstrap.py @@ -0,0 +1,7 @@ +import warnings + + +msg = "bootstrap.py is no longer needed. Use a PEP-517-compatible builder instead." + + +__name__ == '__main__' and warnings.warn(msg) -- cgit v1.2.1