Commit f562d9d8 authored by jim's avatar jim

- Added documentation for some previously undocumented features of the

  easy_install APIs.

- Added an eggs recipe that *just* installes eggs.

- Advertized the scripts recipe for creating scripts.

Updated some tests to deal with the fact that setuptools eggs keep
oscillating between being files and directories.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@72071 62d5b8a3-27da-0310-9561-8e5933582275
parent ed375e65
...@@ -20,6 +20,22 @@ priorities include: ...@@ -20,6 +20,22 @@ priorities include:
Change History Change History
************** **************
1.0.0b18 (2007-01-17)
=====================
Feature Changes
---------------
- Added documentation for some previously undocumented features of the
easy_install APIs.
- Added an eggs recipe that *just* installes eggs.
- Advertized the scripts recipe for creating scripts.
Bugs Fixed
----------
1.0.0b17 (2006-12-07) 1.0.0b17 (2006-12-07)
===================== =====================
......
...@@ -984,7 +984,7 @@ def makeNewRelease(project, ws, dest): ...@@ -984,7 +984,7 @@ def makeNewRelease(project, ws, dest):
) )
zip.close() zip.close()
else: else:
shutil.copy(dist.location, dest) shutil.copytree(dist.location, dest)
info_path = os.path.join(dest, 'EGG-INFO', 'PKG-INFO') info_path = os.path.join(dest, 'EGG-INFO', 'PKG-INFO')
info = open(info_path).read().replace("Version: %s" % oldver, info = open(info_path).read().replace("Version: %s" % oldver,
"Version: 99.99") "Version: 99.99")
...@@ -1057,7 +1057,7 @@ def test_suite(): ...@@ -1057,7 +1057,7 @@ def test_suite():
'__buildout_signature__ = recipes-SSSSSSSSSSS'), '__buildout_signature__ = recipes-SSSSSSSSSSS'),
(re.compile('executable = \S+python\S*'), (re.compile('executable = \S+python\S*'),
'executable = python'), 'executable = python'),
(re.compile('setuptools-\S+[.]egg'), 'setuptools.egg'), (re.compile('[-d] setuptools-\S+[.]egg'), 'setuptools.egg'),
(re.compile('zc.buildout(-\S+)?[.]egg(-link)?'), (re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'), 'zc.buildout.egg'),
(re.compile('creating \S*setup.cfg'), 'creating setup.cfg'), (re.compile('creating \S*setup.cfg'), 'creating setup.cfg'),
...@@ -1080,6 +1080,7 @@ def test_suite(): ...@@ -1080,6 +1080,7 @@ def test_suite():
'\\1.egg'), '\\1.egg'),
(re.compile('(zc.buildout|setuptools)( version)? \d+[.]\d+\S*'), (re.compile('(zc.buildout|setuptools)( version)? \d+[.]\d+\S*'),
'\\1 V.V'), '\\1 V.V'),
(re.compile('[-d] setuptools'), '- setuptools'),
]) ])
), ),
......
...@@ -41,8 +41,10 @@ setup( ...@@ -41,8 +41,10 @@ setup(
install_requires = ['zc.buildout >=1.0.0b3', 'setuptools'], install_requires = ['zc.buildout >=1.0.0b3', 'setuptools'],
tests_require = ['zope.testing'], tests_require = ['zope.testing'],
test_suite = name+'.tests.test_suite', test_suite = name+'.tests.test_suite',
entry_points = {'zc.buildout': ['default = %s:Egg' % name, entry_points = {'zc.buildout': ['default = %s:Scripts' % name,
'script = %s:Egg' % name, 'script = %s:Scripts' % name,
'scripts = %s:Scripts' % name,
'eggs = %s:Eggs' % name,
'custom = %s:Custom' % name, 'custom = %s:Custom' % name,
'develop = %s:Develop' % name, 'develop = %s:Develop' % name,
] ]
......
Installation of distributions as eggs Installation of distributions as eggs
===================================== =====================================
The zc.recipe.egg recipe can be used to install various types if The zc.recipe.egg:eggs recipe can be used to install various types if
distutils distributions as eggs. It takes a number of options: distutils distributions as eggs. It takes a number of options:
eggs eggs
...@@ -29,28 +29,6 @@ python ...@@ -29,28 +29,6 @@ python
Python executable is found in the executable option of the named Python executable is found in the executable option of the named
section. section.
entry-points
A list of entry-point identifiers of the form name=module#attrs,
name is a script name, module is a module name, and a attrs is a
(possibly dotted) name of an object wihin the module. This option
is useful when working with distributions that don't declare entry
points, such as distributions not written to work with setuptools.
scripts
Control which scripts are generated. The value should be a list of
zero or more tokens. Each token is either a name, or a name
followed by an '=' and a new name. Only the named scripts are
generated. If no tokens are given, then script generation is
disabled. If the option isn't given at all, then all scripts
defined by the named eggs will be generated.
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.
extra-paths
Extra paths to include in a generates script.
We have a link server that has a number of distributions: We have a link server that has a number of distributions:
>>> print get(link_server), >>> print get(link_server),
...@@ -65,7 +43,6 @@ We have a link server that has a number of distributions: ...@@ -65,7 +43,6 @@ We have a link server that has a number of distributions:
<a href="other-1.0-py2.3.egg">other-1.0-py2.3.egg</a><br> <a href="other-1.0-py2.3.egg">other-1.0-py2.3.egg</a><br>
</body></html> </body></html>
We have a sample buildout. Let's update it's configuration file to We have a sample buildout. Let's update it's configuration file to
install the demo package. install the demo package.
...@@ -75,7 +52,7 @@ install the demo package. ...@@ -75,7 +52,7 @@ install the demo package.
... parts = demo ... parts = demo
... ...
... [demo] ... [demo]
... recipe = zc.recipe.egg ... recipe = zc.recipe.egg:eggs
... eggs = demo<0.3 ... eggs = demo<0.3
... find-links = %(server)s ... find-links = %(server)s
... index = %(server)s/index ... index = %(server)s/index
...@@ -113,15 +90,59 @@ a regular egg installation.) ...@@ -113,15 +90,59 @@ a regular egg installation.)
Script generation Script generation
----------------- -----------------
The demo egg also defined a script and we see that the script was The demo egg defined a script, but we didn't get one installed:
installed as well:
>>> ls(sample_buildout, 'bin')
- buildout
If we want scripts provided by eggs to be installed, we should use the
scripts recipe:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
...
... [demo]
... recipe = zc.recipe.egg:scripts
... eggs = demo<0.3
... find-links = %(server)s
... index = %(server)s/index
... """ % dict(server=link_server))
>>> print system(buildout),
buildout: Uninstalling demo
buildout: Installing demo
Now we also see the script defined by the dmo script:
>>> ls(sample_buildout, 'bin') >>> ls(sample_buildout, 'bin')
- buildout - buildout
- demo - demo
Here, in addition to the buildout script, we see the demo script, The scripts recipe defines some additional options:
demo.
entry-points
A list of entry-point identifiers of the form name=module#attrs,
name is a script name, module is a module name, and a attrs is a
(possibly dotted) name of an object wihin the module. This option
is useful when working with distributions that don't declare entry
points, such as distributions not written to work with setuptools.
scripts
Control which scripts are generated. The value should be a list of
zero or more tokens. Each token is either a name, or a name
followed by an '=' and a new name. Only the named scripts are
generated. If no tokens are given, then script generation is
disabled. If the option isn't given at all, then all scripts
defined by the named eggs will be generated.
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.
extra-paths
Extra paths to include in a generates script.
Let's add an interpreter option: Let's add an interpreter option:
...@@ -138,6 +159,10 @@ Let's add an interpreter option: ...@@ -138,6 +159,10 @@ Let's add an interpreter option:
... interpreter = py-demo ... interpreter = py-demo
... """ % dict(server=link_server)) ... """ % dict(server=link_server))
Note that we ommitted the entry point name from the recipe
specification. We were able to do this because the scripts recipe if
the default entry point for the zc.recipe.egg egg.
>>> print system(buildout), >>> print system(buildout),
buildout: Uninstalling demo buildout: Uninstalling demo
buildout: Installing demo buildout: Installing demo
...@@ -151,7 +176,6 @@ This is useful for debugging and testing. ...@@ -151,7 +176,6 @@ This is useful for debugging and testing.
- demo - demo
- py-demo - py-demo
If we run the demo script, it prints out some minimal data: If we run the demo script, it prints out some minimal data:
>>> print system(os.path.join(sample_buildout, 'bin', 'demo')), >>> print system(os.path.join(sample_buildout, 'bin', 'demo')),
......
from zc.recipe.egg.egg import Egg from zc.recipe.egg.egg import Egg, Scripts, Eggs
from zc.recipe.egg.custom import Custom, Develop from zc.recipe.egg.custom import Custom, Develop
...@@ -23,7 +23,7 @@ around the egg recipe: ...@@ -23,7 +23,7 @@ around the egg recipe:
... class Sample: ... class Sample:
... ...
... def __init__(self, buildout, name, options): ... def __init__(self, buildout, name, options):
... self.egg = zc.recipe.egg.Egg(buildout, name, options) ... self.egg = zc.recipe.egg.Scripts(buildout, name, options)
... self.name = name ... self.name = name
... self.options = options ... self.options = options
... ...
...@@ -108,7 +108,10 @@ computed by the egg recipe by looking at .installed.cfg: ...@@ -108,7 +108,10 @@ computed by the egg recipe by looking at .installed.cfg:
_b = /sample-buildout/bin _b = /sample-buildout/bin
_d = /sample-buildout/develop-eggs _d = /sample-buildout/develop-eggs
_e = /sample-buildout/eggs _e = /sample-buildout/eggs
bin-directory = /sample-buildout/bin
develop-eggs-directory = /sample-buildout/develop-eggs
eggs = demo<0.3 eggs = demo<0.3
eggs-directory = /sample-buildout/eggs
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/
...@@ -146,3 +149,4 @@ recipe instance: ...@@ -146,3 +149,4 @@ recipe instance:
other 1.0 other 1.0
demoneeded 1.1 demoneeded 1.1
extra paths: ['/foo/bar', '/spam/eggs'] extra paths: ['/foo/bar', '/spam/eggs']
...@@ -19,7 +19,7 @@ $Id$ ...@@ -19,7 +19,7 @@ $Id$
import logging, os, re, zipfile import logging, os, re, zipfile
import zc.buildout.easy_install import zc.buildout.easy_install
class Egg: class Eggs(object):
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
self.buildout = buildout self.buildout = buildout
...@@ -39,17 +39,11 @@ class Egg: ...@@ -39,17 +39,11 @@ class Egg:
options['index'] = index options['index'] = index
self.index = index self.index = index
self.extra_paths = [ options['eggs-directory'] = buildout['buildout']['eggs-directory']
os.path.join(buildout['buildout']['directory'], p.strip()) options['_e'] = options['eggs-directory'] # backward compat.
for p in options.get('extra-paths', '').split('\n') options['develop-eggs-directory'
if p.strip() ] = buildout['buildout']['develop-eggs-directory']
] options['_d'] = options['develop-eggs-directory'] # backward compat.
if self.extra_paths:
options['extra-paths'] = '\n'.join(self.extra_paths)
options['_b'] = buildout['buildout']['bin-directory']
options['_e'] = buildout['buildout']['eggs-directory']
options['_d'] = buildout['buildout']['develop-eggs-directory']
assert options.get('unzip') in ('true', 'false', None) assert options.get('unzip') in ('true', 'false', None)
...@@ -73,20 +67,42 @@ class Egg: ...@@ -73,20 +67,42 @@ class Egg:
if self.buildout['buildout'].get('offline') == 'true': if self.buildout['buildout'].get('offline') == 'true':
ws = zc.buildout.easy_install.working_set( ws = zc.buildout.easy_install.working_set(
distributions, options['executable'], distributions, options['executable'],
[options['_d'], options['_e']] [options['develop-eggs-directory'], options['eggs-directory']]
) )
else: else:
ws = zc.buildout.easy_install.install( ws = zc.buildout.easy_install.install(
distributions, options['_e'], distributions, options['eggs-directory'],
links = self.links, links = self.links,
index = self.index, index = self.index,
executable = options['executable'], executable = options['executable'],
always_unzip=options.get('unzip') == 'true', always_unzip=options.get('unzip') == 'true',
path=[options['_d']] path=[options['develop-eggs-directory']]
) )
return orig_distributions, ws return orig_distributions, ws
def install(self):
reqs, ws = self.working_set()
return ()
update = install
class Scripts(Eggs):
def __init__(self, buildout, name, options):
super(Scripts, self).__init__(buildout, name, options)
options['bin-directory'] = buildout['buildout']['bin-directory']
options['_b'] = options['bin-directory'] # backward compat.
self.extra_paths = [
os.path.join(buildout['buildout']['directory'], p.strip())
for p in options.get('extra-paths', '').split('\n')
if p.strip()
]
if self.extra_paths:
options['extra-paths'] = '\n'.join(self.extra_paths)
parse_entry_point = re.compile( parse_entry_point = re.compile(
'([^=]+)=(\w+(?:[.]\w+)*):(\w+(?:[.]\w+)*)$' '([^=]+)=(\w+(?:[.]\w+)*):(\w+(?:[.]\w+)*)$'
).match ).match
...@@ -113,7 +129,7 @@ class Egg: ...@@ -113,7 +129,7 @@ class Egg:
return zc.buildout.easy_install.scripts( return zc.buildout.easy_install.scripts(
reqs, ws, options['executable'], reqs, ws, options['executable'],
options['_b'], options['bin-directory'],
scripts=scripts, scripts=scripts,
extra_paths=self.extra_paths, extra_paths=self.extra_paths,
interpreter=options.get('interpreter'), interpreter=options.get('interpreter'),
...@@ -122,3 +138,5 @@ class Egg: ...@@ -122,3 +138,5 @@ class Egg:
return () return ()
update = install update = install
Egg = Scripts
...@@ -49,7 +49,7 @@ def test_suite(): ...@@ -49,7 +49,7 @@ def test_suite():
zc.buildout.tests.normalize_bang, zc.buildout.tests.normalize_bang,
(re.compile('zc.buildout(-\S+)?[.]egg(-link)?'), (re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'), 'zc.buildout.egg'),
(re.compile('setuptools-[^-]+-'), 'setuptools-X-') (re.compile('[-d] setuptools-[^-]+-'), 'setuptools-X-')
]) ])
), ),
doctest.DocFileSuite( doctest.DocFileSuite(
......
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