[Checkins] SVN: zc.buildout/trunk/ Finished egglinker doctest.
Jim Fulton
jim at zope.com
Wed Jun 7 19:25:19 EDT 2006
Log message for revision 68520:
Finished egglinker doctest.
Added the ability to control script generation.
Changed:
U zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/README.txt
U zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/egg.py
U zc.buildout/trunk/src/zc/buildout/egglinker.py
-=-
Modified: zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/README.txt
===================================================================
--- zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/README.txt 2006-06-07 23:24:43 UTC (rev 68519)
+++ zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/README.txt 2006-06-07 23:25:19 UTC (rev 68520)
@@ -92,3 +92,77 @@
/tmp/tmpcy8MvGbuildout-tests/eggs/demoneeded-1.0-py2.3.egg
<BLANKLINE>
+The recipe gets the most recent distribution that satisfies the
+specification. For example, if we remove the restriction on demo:
+
+ >>> write(sample_buildout, 'buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = demo
+ ...
+ ... [demo]
+ ... recipe = zc.recipe.egg
+ ... distribution = demo
+ ... find_links = %s
+ ... """ % sample_eggs)
+
+and rerun the buildout:
+
+ >>> print system(runscript),
+
+Then we'll get a new demo egg:
+
+ >>> ls(sample_buildout, 'eggs')
+ - demo-0.2-py2.3.egg
+ - demo-0.3-py2.3.egg
+ - demoneeded-1.0-py2.3.egg
+ - zc.recipe.egg.egg-link
+
+The script is updated too:
+
+ >>> print system(os.path.join(sample_buildout, 'bin', 'demo')),
+ 3 1
+
+You can control which scripts get generated using the scripts option.
+For example, to suppress scripts, use the scripts option without any
+arguments:
+
+
+ >>> write(sample_buildout, 'buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = demo
+ ...
+ ... [demo]
+ ... recipe = zc.recipe.egg
+ ... distribution = demo
+ ... find_links = %s
+ ... scripts =
+ ... """ % sample_eggs)
+
+
+ >>> print system(runscript),
+
+ >>> ls(sample_buildout, 'bin')
+ - buildout
+
+You can also control the name used for scripts:
+
+
+ >>> write(sample_buildout, 'buildout.cfg',
+ ... """
+ ... [buildout]
+ ... parts = demo
+ ...
+ ... [demo]
+ ... recipe = zc.recipe.egg
+ ... distribution = demo
+ ... find_links = %s
+ ... scripts = demo=foo
+ ... """ % sample_eggs)
+
+ >>> print system(runscript),
+
+ >>> ls(sample_buildout, 'bin')
+ - buildout
+ - foo
Modified: zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/egg.py
===================================================================
--- zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/egg.py 2006-06-07 23:24:43 UTC (rev 68519)
+++ zc.buildout/trunk/eggrecipe/src/zc/recipe/egg/egg.py 2006-06-07 23:25:19 UTC (rev 68520)
@@ -44,7 +44,16 @@
[buildout.buildout_path(link) for link in links],
always_copy = True,
)
-
- zc.buildout.egglinker.scripts(
- [distribution], buildout.bin, [buildout.eggs],
- )
+
+ scripts = self.options.get('scripts')
+ if scripts or scripts is None:
+ if scripts is not None:
+ scripts = scripts.split()
+ scripts = dict([
+ ('=' in s) and s.split('=', 1) or (s, s)
+ for s in scripts
+ ])
+ return zc.buildout.egglinker.scripts(
+ [distribution], buildout.bin, [buildout.eggs],
+ scripts=scripts)
+
Modified: zc.buildout/trunk/src/zc/buildout/egglinker.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/egglinker.py 2006-06-07 23:24:43 UTC (rev 68519)
+++ zc.buildout/trunk/src/zc/buildout/egglinker.py 2006-06-07 23:25:19 UTC (rev 68520)
@@ -46,18 +46,40 @@
dist = env.best_match(req, pkg_resources.WorkingSet())
return dist.location
-def scripts(reqs, dest, eggss):
+def scripts(reqs, dest, eggss, scripts=None):
dists = distributions(reqs, eggss)
reqs = [pkg_resources.Requirement.parse(r) for r in reqs]
projects = [r.project_name for r in reqs]
path = "',\n '".join([dist.location for dist in dists])
+ generated = []
for dist in dists:
if dist.project_name in projects:
for name in pkg_resources.get_entry_map(dist, 'console_scripts'):
- _script(dist, name, path, os.path.join(dest, name))
- _pyscript(path, os.path.join(dest, 'py_'+dist.project_name))
+ if scripts is not None:
+ sname = scripts.get(name)
+ if sname is None:
+ continue
+ else:
+ sname = name
+ sname = os.path.join(dest, sname)
+ generated.append(sname)
+ _script(dist, name, path, sname)
+
+ name = 'py_'+dist.project_name
+ if scripts is not None:
+ sname = scripts.get(name)
+ else:
+ sname = name
+
+ if sname is not None:
+ sname = os.path.join(dest, sname)
+ generated.append(sname)
+ _pyscript(path, sname)
+
+ return generated
+
def _script(dist, name, path, dest):
open(dest, 'w').write(script_template % dict(
python = sys.executable,
More information about the Checkins
mailing list