Commit 5137814e authored by Jim Fulton's avatar Jim Fulton

- 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.
parent 9f41469d
......@@ -20,6 +20,22 @@ priorities include:
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)
=====================
......
......@@ -984,7 +984,7 @@ def makeNewRelease(project, ws, dest):
)
zip.close()
else:
shutil.copy(dist.location, dest)
shutil.copytree(dist.location, dest)
info_path = os.path.join(dest, 'EGG-INFO', 'PKG-INFO')
info = open(info_path).read().replace("Version: %s" % oldver,
"Version: 99.99")
......@@ -1057,7 +1057,7 @@ def test_suite():
'__buildout_signature__ = recipes-SSSSSSSSSSS'),
(re.compile('executable = \S+python\S*'),
'executable = python'),
(re.compile('setuptools-\S+[.]egg'), 'setuptools.egg'),
(re.compile('[-d] setuptools-\S+[.]egg'), 'setuptools.egg'),
(re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'),
(re.compile('creating \S*setup.cfg'), 'creating setup.cfg'),
......@@ -1080,6 +1080,7 @@ def test_suite():
'\\1.egg'),
(re.compile('(zc.buildout|setuptools)( version)? \d+[.]\d+\S*'),
'\\1 V.V'),
(re.compile('[-d] setuptools'), '- setuptools'),
])
),
......
......@@ -41,8 +41,10 @@ setup(
install_requires = ['zc.buildout >=1.0.0b3', 'setuptools'],
tests_require = ['zope.testing'],
test_suite = name+'.tests.test_suite',
entry_points = {'zc.buildout': ['default = %s:Egg' % name,
'script = %s:Egg' % name,
entry_points = {'zc.buildout': ['default = %s:Scripts' % name,
'script = %s:Scripts' % name,
'scripts = %s:Scripts' % name,
'eggs = %s:Eggs' % name,
'custom = %s:Custom' % name,
'develop = %s:Develop' % name,
]
......
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:
eggs
......@@ -29,28 +29,6 @@ python
Python executable is found in the executable option of the named
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:
>>> print get(link_server),
......@@ -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>
</body></html>
We have a sample buildout. Let's update it's configuration file to
install the demo package.
......@@ -75,7 +52,7 @@ install the demo package.
... parts = demo
...
... [demo]
... recipe = zc.recipe.egg
... recipe = zc.recipe.egg:eggs
... eggs = demo<0.3
... find-links = %(server)s
... index = %(server)s/index
......@@ -113,15 +90,59 @@ a regular egg installation.)
Script generation
-----------------
The demo egg also defined a script and we see that the script was
installed as well:
The demo egg defined a script, but we didn't get one installed:
>>> 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')
- buildout
- demo
Here, in addition to the buildout script, we see the demo script,
demo.
The scripts recipe defines some additional options:
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:
......@@ -138,6 +159,10 @@ Let's add an interpreter option:
... interpreter = py-demo
... """ % 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),
buildout: Uninstalling demo
buildout: Installing demo
......@@ -151,7 +176,6 @@ This is useful for debugging and testing.
- demo
- py-demo
If we run the demo script, it prints out some minimal data:
>>> 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
......@@ -23,7 +23,7 @@ around the egg recipe:
... class Sample:
...
... 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.options = options
...
......@@ -108,7 +108,10 @@ computed by the egg recipe by looking at .installed.cfg:
_b = /sample-buildout/bin
_d = /sample-buildout/develop-eggs
_e = /sample-buildout/eggs
bin-directory = /sample-buildout/bin
develop-eggs-directory = /sample-buildout/develop-eggs
eggs = demo<0.3
eggs-directory = /sample-buildout/eggs
executable = /usr/local/bin/python2.3
extras = other
find-links = http://localhost:27071/
......@@ -146,3 +149,4 @@ recipe instance:
other 1.0
demoneeded 1.1
extra paths: ['/foo/bar', '/spam/eggs']
......@@ -19,7 +19,7 @@ $Id$
import logging, os, re, zipfile
import zc.buildout.easy_install
class Egg:
class Eggs(object):
def __init__(self, buildout, name, options):
self.buildout = buildout
......@@ -39,18 +39,12 @@ class Egg:
options['index'] = index
self.index = index
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)
options['_b'] = buildout['buildout']['bin-directory']
options['_e'] = buildout['buildout']['eggs-directory']
options['_d'] = buildout['buildout']['develop-eggs-directory']
options['eggs-directory'] = buildout['buildout']['eggs-directory']
options['_e'] = options['eggs-directory'] # backward compat.
options['develop-eggs-directory'
] = buildout['buildout']['develop-eggs-directory']
options['_d'] = options['develop-eggs-directory'] # backward compat.
assert options.get('unzip') in ('true', 'false', None)
python = options.get('python', buildout['buildout']['python'])
......@@ -73,20 +67,42 @@ class Egg:
if self.buildout['buildout'].get('offline') == 'true':
ws = zc.buildout.easy_install.working_set(
distributions, options['executable'],
[options['_d'], options['_e']]
[options['develop-eggs-directory'], options['eggs-directory']]
)
else:
ws = zc.buildout.easy_install.install(
distributions, options['_e'],
distributions, options['eggs-directory'],
links = self.links,
index = self.index,
executable = options['executable'],
always_unzip=options.get('unzip') == 'true',
path=[options['_d']]
path=[options['develop-eggs-directory']]
)
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(
'([^=]+)=(\w+(?:[.]\w+)*):(\w+(?:[.]\w+)*)$'
).match
......@@ -113,7 +129,7 @@ class Egg:
return zc.buildout.easy_install.scripts(
reqs, ws, options['executable'],
options['_b'],
options['bin-directory'],
scripts=scripts,
extra_paths=self.extra_paths,
interpreter=options.get('interpreter'),
......@@ -122,3 +138,5 @@ class Egg:
return ()
update = install
Egg = Scripts
......@@ -49,7 +49,7 @@ def test_suite():
zc.buildout.tests.normalize_bang,
(re.compile('zc.buildout(-\S+)?[.]egg(-link)?'),
'zc.buildout.egg'),
(re.compile('setuptools-[^-]+-'), 'setuptools-X-')
(re.compile('[-d] setuptools-[^-]+-'), 'setuptools-X-')
])
),
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