eggs/zc.buildout-1.5.2-py2.6.egg/zc/buildout/allowhosts.txt
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 Allow hosts
       
     2 -----------
       
     3 
       
     4 On some environments the links visited by `zc.buildout` can be forbidden
       
     5 by paranoiac firewalls. These URL might be on the chain of links
       
     6 visited by `zc.buildout` whether they are defined in the `find-links` option
       
     7 or by various eggs in their `url`, `download_url` and `dependency_links` metadata.
       
     8 
       
     9 It is even harder to track that package_index works like a spider and
       
    10 might visit links and go to other location.
       
    11 
       
    12 The `allow-hosts` option provides a way to prevent this, and
       
    13 works exactly like the one provided in `easy_install`
       
    14 (see `easy_install allow-hosts option`_).
       
    15 
       
    16 You can provide a list of allowed host, together with wildcards::
       
    17 
       
    18     [buildout]
       
    19     ...
       
    20 
       
    21     allow-hosts =
       
    22         *.python.org
       
    23         example.com
       
    24 
       
    25 Let's create a develop egg in our buildout that specifies
       
    26 `dependency_links` which points to a server in the outside world::
       
    27 
       
    28     >>> mkdir(sample_buildout, 'allowdemo')
       
    29     >>> write(sample_buildout, 'allowdemo', 'dependencydemo.py',
       
    30     ...       'import eggrecipekss.core')
       
    31     >>> write(sample_buildout, 'allowdemo', 'setup.py',
       
    32     ... '''from setuptools import setup; setup(
       
    33     ...     name='allowdemo', py_modules=['dependencydemo'],
       
    34     ...     install_requires = 'kss.core',
       
    35     ...     dependency_links = ['http://dist.plone.org'],
       
    36     ...     zip_safe=True, version='1')
       
    37     ... ''')
       
    38 
       
    39 Now let's configure the buildout to use the develop egg,
       
    40 together with some rules that disallow any website but PyPI and
       
    41 local files::
       
    42 
       
    43     >>> write(sample_buildout, 'buildout.cfg',
       
    44     ... '''
       
    45     ... [buildout]
       
    46     ... develop = allowdemo
       
    47     ... parts = eggs
       
    48     ... allow-hosts =
       
    49     ...     pypi.python.org
       
    50     ...
       
    51     ... [eggs]
       
    52     ... recipe = zc.recipe.egg:eggs
       
    53     ... eggs = allowdemo
       
    54     ... ''')
       
    55 
       
    56 Now we can run the buildout and make sure all attempts to dist.plone.org fails::
       
    57 
       
    58     >>> print system(buildout) # doctest: +ELLIPSIS
       
    59     Develop: '/sample-buildout/allowdemo'
       
    60     ...
       
    61     Link to http://dist.plone.org ***BLOCKED*** by --allow-hosts
       
    62     ...
       
    63     While:
       
    64       Installing eggs.
       
    65       Getting distribution for 'kss.core'.
       
    66     Error: Couldn't find a distribution for 'kss.core'.
       
    67     <BLANKLINE>
       
    68 
       
    69 That's what we wanted : this will prevent any attempt to access
       
    70 unwanted domains. For instance, some packages are listing in their
       
    71 links `svn://` links. These can lead to error in some cases, and
       
    72 can therefore be protected like this::
       
    73 
       
    74 XXX (showcase with a svn:// file)
       
    75 
       
    76     >>> write(sample_buildout, 'buildout.cfg',
       
    77     ... '''
       
    78     ... [buildout]
       
    79     ... develop = allowdemo
       
    80     ... parts = eggs
       
    81     ... allow-hosts =
       
    82     ...     ^(!svn://).*
       
    83     ...
       
    84     ... [eggs]
       
    85     ... recipe = zc.recipe.egg:eggs
       
    86     ... eggs = allowdemo
       
    87     ... ''')
       
    88 
       
    89 Now we can run the buildout and make sure all attempts to dist.plone.org fails::
       
    90 
       
    91     >>> print system(buildout) # doctest: +ELLIPSIS
       
    92     Develop: '/sample-buildout/allowdemo'
       
    93     ...
       
    94     Link to http://dist.plone.org ***BLOCKED*** by --allow-hosts
       
    95     ...
       
    96     While:
       
    97       Installing eggs.
       
    98       Getting distribution for 'kss.core'.
       
    99     Error: Couldn't find a distribution for 'kss.core'.
       
   100     <BLANKLINE>
       
   101 
       
   102 Test for issues
       
   103 ---------------
       
   104 
       
   105 Test for 1.0.5 breakage as in https://bugs.launchpad.net/zc.buildout/+bug/239212::
       
   106 
       
   107     >>> write(sample_buildout, 'buildout.cfg',
       
   108     ... '''
       
   109     ... [buildout]
       
   110     ... parts=python
       
   111     ... foo = ${python:interpreter}
       
   112     ...
       
   113     ... [python]
       
   114     ... recipe=zc.recipe.egg
       
   115     ... eggs=zc.buildout
       
   116     ... interpreter=python
       
   117     ... ''')
       
   118     >>> print system(buildout)
       
   119     Unused options for buildout: 'foo'.
       
   120     Installing python.
       
   121     Generated script '/sample-buildout/bin/buildout'.
       
   122     Generated interpreter '/sample-buildout/bin/python'.
       
   123     <BLANKLINE>
       
   124 
       
   125 The bug 239212 above would have got us an *AttributeError* on *buildout._allow_hosts*.
       
   126 This was fixed in this changeset:
       
   127 http://svn.zope.org/zc.buildout/trunk/src/zc/buildout/buildout.py?rev=87309&r1=87277&r2=87309
       
   128