Commit 37d5d52f authored by shane's avatar shane

Added the `dependent-scripts` option. When set to `true`, scripts will

be generated for all required eggs in addition to the eggs named
specifically.

The implementation is short and simple, but testing it required
changes in a lot of places.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@96121 62d5b8a3-27da-0310-9561-8e5933582275
parent c4fecfe2
...@@ -33,6 +33,7 @@ download: ...@@ -33,6 +33,7 @@ download:
>>> print get(link_server), >>> print get(link_server),
<html><body> <html><body>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br> <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br> <a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
<a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br> <a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
......
...@@ -96,6 +96,7 @@ We have a link server that has a number of eggs: ...@@ -96,6 +96,7 @@ We have a link server that has a number of eggs:
>>> print get(link_server), >>> print get(link_server),
<html><body> <html><body>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br> <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br> <a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
<a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br> <a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
...@@ -896,6 +897,7 @@ Let's update our link server with a new version of extdemo: ...@@ -896,6 +897,7 @@ Let's update our link server with a new version of extdemo:
>>> update_extdemo() >>> update_extdemo()
>>> print get(link_server), >>> print get(link_server),
<html><body> <html><body>
<a href="bigdemo-0.1-py2.4.egg">bigdemo-0.1-py2.4.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br> <a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br> <a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
<a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br> <a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
......
...@@ -2628,6 +2628,18 @@ def create_sample_eggs(test, executable=sys.executable): ...@@ -2628,6 +2628,18 @@ def create_sample_eggs(test, executable=sys.executable):
" zip_safe=True, version='0.%s%s')\n" % (i, c1) " zip_safe=True, version='0.%s%s')\n" % (i, c1)
) )
zc.buildout.testing.bdist_egg(tmp, executable, dest) zc.buildout.testing.bdist_egg(tmp, executable, dest)
write(tmp, 'eggrecipebigdemo.py', 'import eggrecipedemo')
write(
tmp, 'setup.py',
"from setuptools import setup\n"
"setup(name='bigdemo', "
" install_requires = 'demo',"
" py_modules=['eggrecipebigdemo'], "
" zip_safe=True, version='0.1')\n"
)
zc.buildout.testing.bdist_egg(tmp, executable, dest)
finally: finally:
shutil.rmtree(tmp) shutil.rmtree(tmp)
......
...@@ -8,6 +8,16 @@ To do ...@@ -8,6 +8,16 @@ To do
Change History Change History
************** **************
1.1.1 (unreleased)
==================
- Added the `dependent-scripts` option. When set to `true`, scripts will
be generated for all required eggs in addition to the eggs named
specifically. This idea came from two forks of this recipe,
`repoze.recipe.egg` and `pylons_sandbox`, but the option name is
spelled with a dash instead of underscore and it defaults to `false`.
1.1.0 (2008-07-19) 1.1.0 (2008-07-19)
================== ==================
......
...@@ -33,6 +33,7 @@ We have a link server that has a number of distributions: ...@@ -33,6 +33,7 @@ We have a link server that has a number of distributions:
>>> print get(link_server), >>> print get(link_server),
<html><body> <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> <a href="demo-0.1-py2.3.egg">demo-0.1-py2.3.egg</a><br>
<a href="demo-0.2-py2.3.egg">demo-0.2-py2.3.egg</a><br> <a href="demo-0.2-py2.3.egg">demo-0.2-py2.3.egg</a><br>
<a href="demo-0.3-py2.3.egg">demo-0.3-py2.3.egg</a><br> <a href="demo-0.3-py2.3.egg">demo-0.3-py2.3.egg</a><br>
...@@ -129,7 +130,7 @@ entry-points ...@@ -129,7 +130,7 @@ entry-points
name=module:attrs name=module:attrs
where name is a script name, module is a dotted name resolving to a where name is a script name, module is a dotted name resolving to a
module name, and a attrs is a dotted name resolving to a callable module name, and attrs is a dotted name resolving to a callable
object within a module. object within a module.
This option is useful when working with distributions that don't This option is useful when working with distributions that don't
...@@ -146,6 +147,10 @@ scripts ...@@ -146,6 +147,10 @@ scripts
disabled. If the option isn't given at all, then all scripts disabled. If the option isn't given at all, then all scripts
defined by the named eggs will be generated. defined by the named eggs will be generated.
dependent-scripts
If set to the string "true", scripts will be generated for all
required eggs in addition to the eggs specifically named.
interpreter interpreter
The name of a script to generate that allows access to a Python The name of a script to generate that allows access to a Python
interpreter that has the path set based on the eggs installed. interpreter that has the path set based on the eggs installed.
...@@ -482,6 +487,31 @@ declare entry points using the entry-points option: ...@@ -482,6 +487,31 @@ declare entry points using the entry-points option:
if __name__ == '__main__': if __name__ == '__main__':
foo.bar.a.b.c() foo.bar.a.b.c()
Generating all scripts
----------------------
The `bigdemo` package doesn't have any scripts, but it requires the `demo`
package, which does have a script. Specify `dependent-scripts = true` to
generate all scripts in required packages:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = bigdemo
...
... [bigdemo]
... recipe = zc.recipe.egg
... find-links = %(server)s
... index = %(server)s/index
... dependent-scripts = true
... """ % dict(server=link_server))
>>> print system(buildout+' -N'),
Uninstalling demo.
Installing bigdemo.
Getting distribution for 'bigdemo'.
Got bigdemo 0.1.
Generated script '/sample-buildout/bin/demo'.
Offline mode Offline mode
------------ ------------
...@@ -501,6 +531,6 @@ be made to contact an index server: ...@@ -501,6 +531,6 @@ be made to contact an index server:
... """ % dict(server=link_server)) ... """ % dict(server=link_server))
>>> print system(buildout), >>> print system(buildout),
Uninstalling demo. Uninstalling bigdemo.
Installing demo. Installing demo.
Generated script '/sample-buildout/bin/foo'. Generated script '/sample-buildout/bin/foo'.
...@@ -76,12 +76,8 @@ class Eggs(object): ...@@ -76,12 +76,8 @@ class Eggs(object):
) )
else: else:
kw = {} kw = {}
always_unzip = options.get('unzip') if options.get('unzip'):
if always_unzip is not None: kw['always_unzip'] = get_bool(options, 'unzip')
if always_unzip not in ('true', 'false'):
raise zc.buildout.UserError("Invalid value for unzip, %s"
% always_unzip)
kw['always_unzip'] = always_unzip == 'true'
ws = zc.buildout.easy_install.install( ws = zc.buildout.easy_install.install(
distributions, options['eggs-directory'], distributions, options['eggs-directory'],
...@@ -141,6 +137,15 @@ class Scripts(Eggs): ...@@ -141,6 +137,15 @@ class Scripts(Eggs):
raise zc.buildout.UserError("Invalid entry point") raise zc.buildout.UserError("Invalid entry point")
reqs.append(parsed.groups()) reqs.append(parsed.groups())
if get_bool(options, 'dependent-scripts'):
# generate scripts for all packages in the working set,
# except setuptools.
reqs = list(reqs)
for dist in ws:
name = dist.project_name
if name != 'setuptools' and name not in reqs:
reqs.append(name)
return zc.buildout.easy_install.scripts( return zc.buildout.easy_install.scripts(
reqs, ws, options['executable'], reqs, ws, options['executable'],
options['bin-directory'], options['bin-directory'],
...@@ -155,4 +160,16 @@ class Scripts(Eggs): ...@@ -155,4 +160,16 @@ class Scripts(Eggs):
update = install update = install
def get_bool(options, name, default=False):
value = options.get(name)
if not value:
return default
if value == 'true':
return True
elif value == 'false':
return False
else:
raise zc.buildout.UserError(
"Invalid value for %s: %s" % (name, value))
Egg = Scripts Egg = Scripts
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