Commit 70c9ae13 authored by Jim Fulton's avatar Jim Fulton

checkpoint

parent 83d53da5
......@@ -55,19 +55,15 @@ local files::
Now we can run the buildout and make sure all attempts to dist.plone.org fails::
>>> print_(system(buildout))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Develop: '/sample-buildout/allowdemo'
Installing eggs.
<BLANKLINE>
Installing eggs...
Link to http://dist.plone.org ***BLOCKED*** by --allow-hosts
<BLANKLINE>
Couldn't find index page for 'kss.core' (maybe misspelled?)
Getting distribution for 'kss.core'.
...
While:
Installing eggs.
Getting distribution for 'kss.core'.
Error: Couldn't find a distribution for 'kss.core'.
<BLANKLINE>
That's what we wanted : this will prevent any attempt to access
unwanted domains. For instance, some packages are listing in their
......@@ -91,19 +87,15 @@ XXX (showcase with a svn:// file)
Now we can run the buildout and make sure all attempts to dist.plone.org fails::
>>> print_(system(buildout))
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Develop: '/sample-buildout/allowdemo'
Installing eggs.
<BLANKLINE>
Installing eggs...
Link to http://dist.plone.org ***BLOCKED*** by --allow-hosts
<BLANKLINE>
Couldn't find index page for 'kss.core' (maybe misspelled?)
Getting distribution for 'kss.core'.
...
While:
Installing eggs.
Getting distribution for 'kss.core'.
Error: Couldn't find a distribution for 'kss.core'.
<BLANKLINE>
Test for issues
---------------
......@@ -121,15 +113,14 @@ Test for 1.0.5 breakage as in https://bugs.launchpad.net/zc.buildout/+bug/239212
... eggs=zc.buildout
... interpreter=python
... ''')
>>> print_('XX'; print system(buildout)) # doctest: +ELLIPSIS
>>> print_('XX'); print_(system(buildout), end='') # doctest: +ELLIPSIS
X...
Unused options for buildout: 'foo'.
Installing python.
Generated script '/sample-buildout/bin/buildout'.
Generated interpreter '/sample-buildout/bin/python'.
<BLANKLINE>
The bug 239212 above would have got us an *AttributeError* on *buildout._allow_hosts*.
This was fixed in this changeset:
The bug 239212 above would have got us an *AttributeError* on
*buildout._allow_hosts*. This was fixed in this changeset:
http://svn.zope.org/zc.buildout/trunk/src/zc/buildout/buildout.py?rev=87309&r1=87277&r2=87309
......@@ -20,7 +20,7 @@ Make sure the bootstrap script actually works::
... parts =
... ''')
>>> write('bootstrap.py', open(bootstrap_py).read())
>>> print_('X'; print system(
>>> print_('X'); print_(system(
... zc.buildout.easy_install._safe_arg(sys.executable)+' '+
... 'bootstrap.py')); print_('X') # doctest: +ELLIPSIS
X...
......
......@@ -82,11 +82,10 @@ buildout to see where the egg comes from this time.
... for egg in glob(join(sample_buildout, 'eggs', 'demoneeded*.egg')):
... remove(sample_buildout, 'eggs', egg)
>>> remove_demoneeded_egg()
>>> print_(system(buildout), end='')
>>> print_(system(buildout), end='') # doctest: +ELLIPSIS
Develop: '/sample-buildout/depdemo'
Updating eggs.
Couldn't find index page for 'demoneeded' (maybe misspelled?)
Getting distribution for 'demoneeded'.
...
While:
Updating eggs.
Getting distribution for 'demoneeded'.
......
......@@ -23,6 +23,7 @@ import os
import os.path
import re
import shutil
import sys
import tempfile
import urllib.request, urllib.parse, urllib.error
import urllib.parse
......@@ -183,7 +184,7 @@ class Download(object):
e = sys.exc_info()[1]
os.remove(tmp_path)
raise zc.buildout.UserError("Error downloading extends for URL "
"%s: %r" % (url, e[1:3]))
"%s: %s" % (url, e))
except Exception:
os.remove(tmp_path)
raise
......@@ -201,7 +202,7 @@ class Download(object):
"""
if self.hash_name:
return md5(url).hexdigest()
return md5(url.encode()).hexdigest()
else:
if re.match(r"^[A-Za-z]:\\", url):
url = 'file:' + url
......
......@@ -75,13 +75,13 @@ We can also have the downloaded file's MD5 sum checked:
... except ImportError: from md5 import new as md5
>>> path, is_temp = download(server_url+'foo.txt',
... md5('This is a foo text.').hexdigest())
... md5('This is a foo text.'.encode()).hexdigest())
>>> is_temp
True
>>> remove(path)
>>> download(server_url+'foo.txt',
... md5('The wrong text.').hexdigest())
... md5('The wrong text.'.encode()).hexdigest())
Traceback (most recent call last):
ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
......@@ -89,11 +89,11 @@ The error message in the event of an MD5 checksum mismatch for a local file
reads somewhat differently:
>>> download(join(server_data, 'foo.txt'),
... md5('This is a foo text.').hexdigest())
... md5('This is a foo text.'.encode()).hexdigest())
('/sample_files/foo.txt', False)
>>> download(join(server_data, 'foo.txt'),
... md5('The wrong text.').hexdigest())
... md5('The wrong text.'.encode()).hexdigest())
Traceback (most recent call last):
ChecksumError: MD5 checksum mismatch for local resource at '/sample_files/foo.txt'.
......@@ -168,7 +168,7 @@ This is a foo text.
If we specify an MD5 checksum for a file that is already in the cache, the
cached copy's checksum will be verified:
>>> download(server_url+'foo.txt', md5('The wrong text.').hexdigest())
>>> download(server_url+'foo.txt', md5('The wrong text.'.encode()).hexdigest())
Traceback (most recent call last):
ChecksumError: MD5 checksum mismatch for cached download
from 'http://localhost/foo.txt' at '/download-cache/foo.txt'
......@@ -247,7 +247,7 @@ This is a foo text.
However, resources with checksum mismatches will not be copied to the cache:
>>> download(server_url+'foo.txt', md5('The wrong text.').hexdigest())
>>> download(server_url+'foo.txt', md5('The wrong text.'.encode()).hexdigest())
Traceback (most recent call last):
ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
>>> ls(cache)
......@@ -256,9 +256,11 @@ ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
If the file is completely missing it should notify the user of the error:
>>> download(server_url+'bar.txt')
>>> download(server_url+'bar.txt') # doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
UserError: Error downloading extends for URL http://localhost/bar.txt: (404, 'Not Found')
...
UserError: Error downloading extends for URL http://localhost/bar.txt:
HTTP Error 404: Not Found
>>> ls(cache)
Finally, let's see what happens if the download cache to be used doesn't exist
......@@ -344,7 +346,8 @@ checksum since we don't know which port the server happens to listen at when
the test is run, so we don't actually know the full URL of the file. Let's
check that the checksum actually belongs to the particular URL used:
>>> path.lower() == join(cache, md5(server_url+'foo.txt').hexdigest()).lower()
>>> (path.lower() ==
... join(cache, md5((server_url+'foo.txt').encode()).hexdigest()).lower())
True
The cached copy is used when downloading the file again:
......@@ -366,7 +369,9 @@ cache under a different name:
/download-cache/537b6d73267f8f4447586989af8c470e
>>> path == path2
False
>>> path2.lower() == join(cache, md5(server_url+'other/foo.txt').hexdigest()).lower()
>>> (path2.lower() ==
... join(cache, md5((server_url+'other/foo.txt').encode()).hexdigest()
... ).lower())
True
>>> cat(path)
This is a foo text.
......@@ -446,7 +451,7 @@ When trying to download a resource whose checksum does not match, the cached
copy will neither be used nor overwritten:
>>> write(server_data, 'foo.txt', 'This is a foo text.')
>>> download(server_url+'foo.txt', md5('The wrong text.').hexdigest())
>>> download(server_url+'foo.txt', md5('The wrong text.'.encode()).hexdigest())
Traceback (most recent call last):
ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
>>> cat(cache, 'foo.txt')
......@@ -539,9 +544,10 @@ conversions:
>>> text = 'First line of text.\r\nSecond line.\r\n'
>>> f = open(join(server_data, 'foo.txt'), 'wb')
>>> f.write(text)
>>> _ = f.write(text.encode())
>>> f.close()
>>> path, is_temp = Download()(server_url+'foo.txt', md5(text).hexdigest())
>>> path, is_temp = Download()(server_url+'foo.txt',
... md5(text.encode()).hexdigest())
>>> remove(path)
When "downloading" a directory given by file-system path or ``file:`` URL and
......
......@@ -22,7 +22,7 @@ To see how this works, we'll create two versions of a recipe egg:
>>> write('recipe', 'recipe.py',
... '''
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\n')
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\\n')
... class Recipe:
... def __init__(*a): pass
... def install(self):
......@@ -50,7 +50,7 @@ To see how this works, we'll create two versions of a recipe egg:
>>> write('recipe', 'recipe.py',
... '''
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\n')
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\\n')
... class Recipe:
... def __init__(*a): pass
... def install(self):
......
......@@ -18,7 +18,7 @@ To illustrate this, we'll create a package in a sample buildout:
>>> mkdir('hello')
>>> write('hello', 'hello.py',
... 'import sys; sys.stdout.write("Hello World!\n")\n')
... 'import sys; sys.stdout.write("Hello World!\\n")\n')
>>> write('hello', 'README', 'This is hello')
>>> write('hello', 'setup.py',
... """
......
This diff is collapsed.
......@@ -35,7 +35,7 @@ zc.buildout used:
... """
... import pkg_resources
... import sys
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\n')
... print_ = lambda *a: sys.stdout.write(' '.join(map(str, a))+'\\n')
...
... class Recipe:
...
......@@ -66,15 +66,18 @@ Now if we run the buildout, the buildout will upgrade itself to the
new versions found in new releases:
>>> print_(system(buildout), end='')
Getting distribution for 'zc.buildout'.
Got zc.buildout 99.99.
Getting distribution for 'distribute'.
Got distribute 99.99.
Upgraded:
zc.buildout version 99.99,
distribute version 99.99;
restarting.
Generated script '/sample-buildout/bin/buildout'.
Develop: '/sample-buildout/showversions'
Installing show-versions.
zc.buildout 1.4.4
zc.buildout 99.99
distribute 99.99
Our buildout script has been updated to use the new eggs:
......@@ -84,7 +87,7 @@ Our buildout script has been updated to use the new eggs:
<BLANKLINE>
import sys
sys.path[0:0] = [
'/sample-buildout/eggs/zc.buildout-1.4.4-py2.4.egg',
'/sample-buildout/eggs/zc.buildout-99.99-py2.4.egg',
'/sample-buildout/eggs/distribute-99.99-py2.4.egg',
]
<BLANKLINE>
......@@ -115,6 +118,7 @@ Now we can see that we actually "upgrade" to an earlier version.
>>> print_(system(buildout), end='')
Upgraded:
zc.buildout version 1.4.4;
distribute version 0.6;
restarting.
Generated script '/sample-buildout/bin/buildout'.
......@@ -140,7 +144,7 @@ We won't upgrade in offline mode:
... recipe = showversions
... """ % dict(new_releases=new_releases))
>>> print_(system(buildout+' -o'), ed='')
>>> print_(system(buildout+' -o'), end='')
Develop: '/sample-buildout/showversions'
Updating show-versions.
zc.buildout 1.0.0
......@@ -173,6 +177,8 @@ directory:
Creating directory '/sample_buildout2/parts'.
Creating directory '/sample_buildout2/eggs'.
Creating directory '/sample_buildout2/develop-eggs'.
Getting distribution for 'zc.buildout'.
Got zc.buildout 99.99.
Getting distribution for 'distribute'.
Got distribute 99.99.
Not upgrading because not running a local buildout command.
......
......@@ -25,7 +25,7 @@ index
We have a link server that has a number of distributions:
>>> print get(link_server),
>>> print_(get(link_server), end='')
<html><body>
<a href="bigdemo-0.1-py2.3.egg">bigdemo-0.1-py2.3.egg</a><br>
<a href="demo-0.1-py2.3.egg">demo-0.1-py2.3.egg</a><br>
......@@ -62,7 +62,7 @@ specified where to find distributions using the find-links option.
Let's run the buildout:
>>> import os
>>> print system(buildout),
>>> print_(system(buildout), end='')
Installing demo.
Getting distribution for 'demo<0.3'.
Got demo 0.2.
......@@ -106,7 +106,7 @@ scripts recipe:
... index = %(server)s/index
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/demo'.
......@@ -186,7 +186,7 @@ Note that we ommitted the entry point name from the recipe
specification. We were able to do this because the scripts recipe is
the default entry point for the zc.recipe.egg egg.
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/demo'.
......@@ -203,20 +203,20 @@ This is useful for debugging and testing.
If we run the demo script, it prints out some minimal data:
>>> print system(join(sample_buildout, 'bin', 'demo')),
>>> print_(system(join(sample_buildout, 'bin', 'demo')), end='')
2 2
The value it prints out happens to be some values defined in the
modules installed.
We can also run the py-demo script. Here we'll just print out
We can also run the py-demo script. Here we'll just print_(out)
the bits if the path added to reflect the eggs:
>>> print system(join(sample_buildout, 'bin', 'py-demo'),
>>> print_(system(join(sample_buildout, 'bin', 'py-demo'), end='')
... """import os, sys
... for p in sys.path:
... if 'demo' in p:
... print os.path.basename(p)
... print_(os.path.basename(p))
...
... """).replace('>>> ', '').replace('... ', ''),
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
......@@ -244,7 +244,7 @@ remove the restriction on demo:
and run the buildout in non-newest mode:
>>> print system(buildout+' -N'),
>>> print_(system(buildout+' -N'), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/demo'.
......@@ -255,7 +255,7 @@ reinstalled.
We'll also run the buildout in off-line mode:
>>> print system(buildout+' -o'),
>>> print_(system(buildout+' -o'), end='')
Updating demo.
We didn't get an update for demo:
......@@ -269,7 +269,7 @@ We didn't get an update for demo:
If we run the buildout on the default online and newest modes,
we'll get an update for demo:
>>> print system(buildout),
>>> print_(system(buildout), end='')
Updating demo.
Getting distribution for 'demo'.
Got demo 0.4c1.
......@@ -286,7 +286,7 @@ Then we'll get a new demo egg:
The script is updated too:
>>> print system(join(sample_buildout, 'bin', 'demo')),
>>> print_(system(join(sample_buildout, 'bin', 'demo')), end='')
4 2
Controlling script generation
......@@ -309,7 +309,7 @@ arguments:
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
......@@ -330,7 +330,7 @@ You can also control the name used for scripts:
... scripts = demo=foo
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
......@@ -360,7 +360,7 @@ extra-paths option:
... ${buildout:directory}/spam
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
......@@ -407,7 +407,7 @@ breaking scripts.
... ${buildout:directory}/spam
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
......@@ -456,7 +456,7 @@ each individual script section:
... ${buildout:directory}/spam
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
......@@ -509,7 +509,7 @@ to be included in generated scripts:
... arguments = a, 2
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
......@@ -559,7 +559,7 @@ declare entry points using the entry-points option:
... entry-points = alt=eggrecipedemo:alt other=foo.bar:a.b.c
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling demo.
Installing demo.
Generated script '/sample-buildout/bin/demo'.
......@@ -606,7 +606,7 @@ generate all scripts in required packages:
... index = %(server)s/index
... dependent-scripts = true
... """ % dict(server=link_server))
>>> print system(buildout+' -N'),
>>> print_(system(buildout+' -N'), end='')
Uninstalling demo.
Installing bigdemo.
Getting distribution for 'bigdemo'.
......@@ -631,7 +631,7 @@ be made to contact an index server:
... scripts = demo=foo
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Uninstalling bigdemo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
......@@ -17,9 +17,12 @@ around the egg recipe:
>>> mkdir(sample_buildout, 'sample')
>>> write(sample_buildout, 'sample', 'sample.py',
... """
... import logging, os
... import logging, os, sys
... import zc.recipe.egg
...
... def print_(*args):
... sys.stdout.write(' '.join(map(str, args)))
...
... class Sample:
...
... def __init__(self, buildout, name, options):
......@@ -30,14 +33,14 @@ around the egg recipe:
... def install(self):
... extras = self.options['extras'].split()
... requirements, ws = self.egg.working_set(extras)
... print 'Part:', self.name
... print 'Egg requirements:'
... print_('Part:', self.name)
... print_('Egg requirements:')
... for r in requirements:
... print r
... print 'Working set:'
... print_(r)
... print_('Working set:')
... for d in ws:
... print d
... print 'extra paths:', self.egg.extra_paths
... print_(d)
... print_('extra paths:', self.egg.extra_paths)
... return ()
...
... update = install
......@@ -81,7 +84,7 @@ of extra requirements to be included in the working set.
>>> import os
>>> os.chdir(sample_buildout)
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print system(buildout + ' -q'),
>>> print_(system(buildout + ' -q'), end='')
Part: sample-part
Egg requirements:
demo<0.3
......@@ -139,7 +142,7 @@ If we use the extra-paths option:
Then we'll see that reflected in the extra_paths attribute in the egg
recipe instance:
>>> print system(buildout + ' -q'),
>>> print_(system(buildout + ' -q'), end='')
Part: sample-part
Egg requirements:
demo<0.3
......
......@@ -131,7 +131,7 @@ the egg:
...
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Installing extdemo.
zip_safe flag not set; analyzing archive contents...
......@@ -156,9 +156,11 @@ Let's define a script that uses out ext demo:
>>> mkdir('demo')
>>> write('demo', 'demo.py',
... """
... import extdemo
... import extdemo, sys
... def print_(*args):
... sys.stdout.write(' '.join(map(str, args)))
... def main():
... print extdemo.val
... print_(extdemo.val)
... """)
>>> write('demo', 'setup.py',
......@@ -187,7 +189,7 @@ Let's define a script that uses out ext demo:
... entry-points = demo=demo:main
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/demo'
Updating extdemo.
Installing demo.
......@@ -195,7 +197,7 @@ Let's define a script that uses out ext demo:
When we run the script, we'll 42 printed:
>>> print system(join('bin', 'demo')),
>>> print_(system(join('bin', 'demo')), end='')
42
Updating
......@@ -210,12 +212,12 @@ distribution for extdemo:
If we run the buildout in non-newest or offline modes:
>>> print system(buildout+' -N'),
>>> print_(system(buildout+' -N'), end='')
Develop: '/sample-buildout/demo'
Updating extdemo.
Updating demo.
>>> print system(buildout+' -o'),
>>> print_(system(buildout+' -o'), end='')
Develop: '/sample-buildout/demo'
Updating extdemo.
Updating demo.
......@@ -231,7 +233,7 @@ But if we run the buildout in the default on-line and newest modes, we
will. This time we also get the test-variable message again, because the new
version is imported:
>>> print system(buildout),
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/demo'
Updating extdemo.
zip_safe flag not set; analyzing archive contents...
......@@ -269,7 +271,7 @@ We can specify a specific version using the egg option:
... entry-points = demo=demo:main
... """ % dict(server=link_server))
>>> print system(buildout+' -D'),
>>> print_(system(buildout+' -D'), end='')
Develop: '/sample-buildout/demo'
Uninstalling demo.
Uninstalling extdemo.
......@@ -345,7 +347,7 @@ Create our buildout:
... recipe = recipes:environ
...
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Uninstalling demo.
Uninstalling extdemo.
......@@ -365,7 +367,7 @@ the original value will be restored:
>>> import os
>>> os.environ['test-variable'] = 'bar'
>>> print system(buildout),
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Updating extdemo.
Updating checkenv.
......@@ -399,7 +401,7 @@ are interpolated with os.environ before the're set:
... recipe = recipes:environ
...
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Uninstalling extdemo.
Installing extdemo.
......@@ -428,7 +430,7 @@ Create a clean buildout.cfg w/o the checkenv recipe, and delete the recipe:
... include-dirs = include
...
... """ % dict(server=link_server))
>>> print system(buildout),
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/recipes'
Uninstalling checkenv.
Uninstalling extdemo.
......@@ -529,7 +531,7 @@ Note that we added a define option to cause the preprocessor variable
TWO to be defined. This will cause the module-variable, 'val', to be
set with a value of 2.
>>> print system(buildout),
>>> print_(system(buildout), end='')
Develop: '/sample-buildout/demo'
Uninstalling extdemo.
Installing extdemo.
......@@ -558,5 +560,5 @@ and the extdemo now has a built extension:
Because develop eggs take precedence over non-develop eggs, the demo
script will use the new develop egg:
>>> print system(join('bin', 'demo')),
>>> print_(system(join('bin', 'demo')), end='')
2
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment