Commit 0decc585 authored by Shane Hathaway's avatar Shane Hathaway

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.
parent a65f510c
......@@ -33,6 +33,7 @@ download:
>>> print get(link_server),
<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.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>
......
......@@ -96,6 +96,7 @@ We have a link server that has a number of eggs:
>>> print get(link_server),
<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.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>
......@@ -896,6 +897,7 @@ Let's update our link server with a new version of extdemo:
>>> update_extdemo()
>>> print get(link_server),
<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.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>
......
......@@ -2628,6 +2628,18 @@ def create_sample_eggs(test, executable=sys.executable):
" zip_safe=True, version='0.%s%s')\n" % (i, c1)
)
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:
shutil.rmtree(tmp)
......
......@@ -8,6 +8,16 @@ To do
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)
==================
......
......@@ -33,6 +33,7 @@ We have a link server that has a number of distributions:
>>> print get(link_server),
<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.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>
......@@ -129,7 +130,7 @@ entry-points
name=module:attrs
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.
This option is useful when working with distributions that don't
......@@ -146,6 +147,10 @@ scripts
disabled. If the option isn't given at all, then all scripts
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
The name of a script to generate that allows access to a Python
interpreter that has the path set based on the eggs installed.
......@@ -482,6 +487,31 @@ declare entry points using the entry-points option:
if __name__ == '__main__':
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
------------
......@@ -501,6 +531,6 @@ be made to contact an index server:
... """ % dict(server=link_server))
>>> print system(buildout),
Uninstalling demo.
Uninstalling bigdemo.
Installing demo.
Generated script '/sample-buildout/bin/foo'.
......@@ -76,12 +76,8 @@ class Eggs(object):
)
else:
kw = {}
always_unzip = options.get('unzip')
if always_unzip is not None:
if always_unzip not in ('true', 'false'):
raise zc.buildout.UserError("Invalid value for unzip, %s"
% always_unzip)
kw['always_unzip'] = always_unzip == 'true'
if options.get('unzip'):
kw['always_unzip'] = get_bool(options, 'unzip')
ws = zc.buildout.easy_install.install(
distributions, options['eggs-directory'],
......@@ -141,6 +137,15 @@ class Scripts(Eggs):
raise zc.buildout.UserError("Invalid entry point")
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(
reqs, ws, options['executable'],
options['bin-directory'],
......@@ -155,4 +160,16 @@ class Scripts(Eggs):
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
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