Commit b3c0829a authored by Gary Poster's avatar Gary Poster

add option to script generation in zc.recipe.egg to import site.

parent 9aee1376
...@@ -15,7 +15,7 @@ To illustrate, we create a sample recipe that is a very thin layer ...@@ -15,7 +15,7 @@ To illustrate, we create a sample recipe that is a very thin layer
around the egg recipe: around the egg recipe:
>>> mkdir(sample_buildout, 'sample') >>> mkdir(sample_buildout, 'sample')
>>> write(sample_buildout, 'sample', 'sample.py', >>> write(sample_buildout, 'sample', 'sample.py',
... """ ... """
... import logging, os ... import logging, os
... import zc.recipe.egg ... import zc.recipe.egg
...@@ -53,7 +53,7 @@ of extra requirements to be included in the working set. ...@@ -53,7 +53,7 @@ of extra requirements to be included in the working set.
>>> write(sample_buildout, 'sample', 'setup.py', >>> write(sample_buildout, 'sample', 'setup.py',
... """ ... """
... from setuptools import setup ... from setuptools import setup
... ...
... setup( ... setup(
... name = "sample", ... name = "sample",
... entry_points = {'zc.buildout': ['default = sample:Sample']}, ... entry_points = {'zc.buildout': ['default = sample:Sample']},
...@@ -95,12 +95,13 @@ We can see that the options were augmented with additional data ...@@ -95,12 +95,13 @@ We can see that the options were augmented with additional data
computed by the egg recipe by looking at .installed.cfg: computed by the egg recipe by looking at .installed.cfg:
>>> cat(sample_buildout, '.installed.cfg') >>> cat(sample_buildout, '.installed.cfg')
... # doctest: +NORMALIZE_WHITESPACE
[buildout] [buildout]
installed_develop_eggs = /sample-buildout/develop-eggs/sample.egg-link installed_develop_eggs = /sample-buildout/develop-eggs/sample.egg-link
parts = sample-part parts = sample-part
<BLANKLINE> <BLANKLINE>
[sample-part] [sample-part]
__buildout_installed__ = __buildout_installed__ =
__buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ== __buildout_signature__ = sample-6aWMvV2EJ9Ijq+bR8ugArQ==
zc.recipe.egg-cAsnudgkduAa/Fd+WJIM6Q== zc.recipe.egg-cAsnudgkduAa/Fd+WJIM6Q==
setuptools-0.6-py2.4.egg setuptools-0.6-py2.4.egg
...@@ -115,7 +116,9 @@ computed by the egg recipe by looking at .installed.cfg: ...@@ -115,7 +116,9 @@ computed by the egg recipe by looking at .installed.cfg:
executable = /usr/local/bin/python2.3 executable = /usr/local/bin/python2.3
extras = other extras = other
find-links = http://localhost:27071/ find-links = http://localhost:27071/
include-site-packages = false
index = http://localhost:27071/index index = http://localhost:27071/index
python = buildout
recipe = sample recipe = sample
If we use the extra-paths option: If we use the extra-paths option:
......
...@@ -52,7 +52,7 @@ class Eggs(object): ...@@ -52,7 +52,7 @@ class Eggs(object):
# verify that this is None, 'true' or 'false' # verify that this is None, 'true' or 'false'
get_bool(options, 'unzip') get_bool(options, 'unzip')
python = options.get('python', b_options['python']) python = options.setdefault('python', b_options['python'])
options['executable'] = buildout[python]['executable'] options['executable'] = buildout[python]['executable']
def working_set(self, extra=()): def working_set(self, extra=()):
...@@ -70,10 +70,11 @@ class Eggs(object): ...@@ -70,10 +70,11 @@ class Eggs(object):
orig_distributions = distributions[:] orig_distributions = distributions[:]
distributions.extend(extra) distributions.extend(extra)
if self.buildout['buildout'].get('offline') == 'true': if b_options.get('offline') == 'true':
ws = zc.buildout.easy_install.working_set( ws = zc.buildout.easy_install.working_set(
distributions, options['executable'], distributions, options['executable'],
[options['develop-eggs-directory'], options['eggs-directory']] [options['develop-eggs-directory'],
options['eggs-directory']],
) )
else: else:
kw = {} kw = {}
...@@ -85,7 +86,7 @@ class Eggs(object): ...@@ -85,7 +86,7 @@ class Eggs(object):
index=self.index, index=self.index,
executable=options['executable'], executable=options['executable'],
path=[options['develop-eggs-directory']], path=[options['develop-eggs-directory']],
newest=self.buildout['buildout'].get('newest') == 'true', newest=b_options.get('newest') == 'true',
allow_hosts=self.allow_hosts, allow_hosts=self.allow_hosts,
**kw) **kw)
...@@ -102,11 +103,13 @@ class Scripts(Eggs): ...@@ -102,11 +103,13 @@ class Scripts(Eggs):
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
super(Scripts, self).__init__(buildout, name, options) super(Scripts, self).__init__(buildout, name, options)
options['bin-directory'] = buildout['buildout']['bin-directory'] b_options = buildout['buildout']
options['bin-directory'] = b_options['bin-directory']
options['_b'] = options['bin-directory'] # backward compat. options['_b'] = options['bin-directory'] # backward compat.
self.extra_paths = [ self.extra_paths = [
os.path.join(buildout['buildout']['directory'], p.strip()) os.path.join(b_options['directory'], p.strip())
for p in options.get('extra-paths', '').split('\n') for p in options.get('extra-paths', '').split('\n')
if p.strip() if p.strip()
] ]
...@@ -115,16 +118,23 @@ class Scripts(Eggs): ...@@ -115,16 +118,23 @@ class Scripts(Eggs):
relative_paths = options.get( relative_paths = options.get(
'relative-paths', 'relative-paths', b_options.get('relative-paths', 'false'))
buildout['buildout'].get('relative-paths', 'false')
)
if relative_paths == 'true': if relative_paths == 'true':
options['buildout-directory'] = buildout['buildout']['directory'] options['buildout-directory'] = b_options['directory']
self._relative_paths = options['buildout-directory'] self._relative_paths = options['buildout-directory']
else: else:
self._relative_paths = '' self._relative_paths = ''
assert relative_paths == 'false' assert relative_paths == 'false'
value = options.setdefault(
'include-site-packages',
b_options.get('include-site-packages', 'false'))
if value not in ('true', 'false'):
raise zc.buildout.UserError(
"Invalid value for include-site-packages option: %s" %
(value,))
self.include_site_packages = (value == 'true')
parse_entry_point = re.compile( parse_entry_point = re.compile(
'([^=]+)=(\w+(?:[.]\w+)*):(\w+(?:[.]\w+)*)$' '([^=]+)=(\w+(?:[.]\w+)*):(\w+(?:[.]\w+)*)$'
).match ).match
...@@ -167,6 +177,7 @@ class Scripts(Eggs): ...@@ -167,6 +177,7 @@ class Scripts(Eggs):
initialization=options.get('initialization', ''), initialization=options.get('initialization', ''),
arguments=options.get('arguments', ''), arguments=options.get('arguments', ''),
relative_paths=self._relative_paths, relative_paths=self._relative_paths,
import_site=self.include_site_packages,
) )
return () return ()
......
...@@ -36,7 +36,7 @@ def setUp(test): ...@@ -36,7 +36,7 @@ def setUp(test):
def setUpSelecting(test): def setUpSelecting(test):
zc.buildout.testselectingpython.setup(test) zc.buildout.testselectingpython.setup(test)
zc.buildout.testing.install_develop('zc.recipe.egg', test) zc.buildout.testing.install_develop('zc.recipe.egg', test)
def test_suite(): def test_suite():
suite = unittest.TestSuite(( suite = unittest.TestSuite((
doctest.DocFileSuite( doctest.DocFileSuite(
...@@ -67,7 +67,7 @@ def test_suite(): ...@@ -67,7 +67,7 @@ def test_suite():
'setuptools-\S+\s+' 'setuptools-\S+\s+'
'zc.buildout-\S+\s*' 'zc.buildout-\S+\s*'
), ),
'__buildout_signature__ = sample- zc.recipe.egg-'), '__buildout_signature__ = sample- zc.recipe.egg-\n'),
(re.compile('executable = [\S ]+python\S*', re.I), (re.compile('executable = [\S ]+python\S*', re.I),
'executable = python'), 'executable = python'),
(re.compile('find-links = http://localhost:\d+/'), (re.compile('find-links = http://localhost:\d+/'),
...@@ -89,7 +89,7 @@ def test_suite(): ...@@ -89,7 +89,7 @@ def test_suite():
(re.compile('extdemo[.]pyd'), 'extdemo.so') (re.compile('extdemo[.]pyd'), 'extdemo.so')
]), ]),
), ),
)) ))
if sys.version_info[:2] == (2, 5): if sys.version_info[:2] == (2, 5):
...@@ -115,7 +115,7 @@ def test_suite(): ...@@ -115,7 +115,7 @@ def test_suite():
]), ]),
), ),
) )
return suite return suite
if __name__ == '__main__': if __name__ == '__main__':
......
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