Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
fix eggbox _script
Browse files Browse the repository at this point in the history
  • Loading branch information
dobe committed Jan 28, 2010
1 parent 13e190d commit 6c6aac5
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 40 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changes for lovely.recipe
=========================

trunk
=====

- fixed script generation in eggbox recipe, thanks to Jens Klein for
reporting this.

2009/08/27 1.0.0b6
==================

Expand Down
6 changes: 5 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[buildout]
develop = .
parts = test importchecker
versions = versions

[test]
recipe = zc.recipe.testrunner
Expand All @@ -9,4 +10,7 @@ defaults = ['--auto-color']

[importchecker]
recipe = lovely.recipe:importchecker
path = src/lovely
path = src/lovely

[versions]
zc.buildout=1.4.3
79 changes: 44 additions & 35 deletions src/lovely/recipe/egg/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,66 +17,87 @@ use the recipe.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = %s
... develop = %(loc)s
... parts = packages
... find-links = %(server)s
... index = %(server)s/index
...
... [packages]
... recipe = lovely.recipe:eggbox
... eggs = pytz
... eggs = demo
... lovely.recipe
... interpreter = py
... """ % lovely_recipy_loc)
... """ % dict(loc=lovely_recipy_loc, server=link_server))

>>> 'Installing packages.' in system(buildout + ' -o')
True

>>> print system(buildout)
Develop: '...lovely.recipe'
Getting distribution for 'demo'.
Got demo 0.4c1.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Installing packages.
Generated script '...sample-buildout/bin/demo'.
Generated interpreter '...sample-buildout/bin/py'.

We now have a zip file for each top-level directory. Note that the
zip-files are ending with .egg for pkg_resources compatibility.

>>> ls(sample_buildout + '/parts/packages')
- easy_install.py.egg
- eggrecipedemo.py.egg
- eggrecipedemoneeded.py.egg
- lovely.egg
- pytz.egg
- pkg_resources.py.egg
- setuptools.egg
- zc.egg

The generated interpreter now has the pytz zip file in the path.
The generated interpreter now has the demo zip file in the path.

>>> cat(sample_buildout + '/bin/py')
#!...
sys.path[0:0] = [
'/sample-buildout/parts/packages/easy_install.py.egg',
'/sample-buildout/parts/packages/eggrecipedemo.py.egg',
'/sample-buildout/parts/packages/eggrecipedemoneeded.py.egg',
'/sample-buildout/parts/packages/lovely.egg',
'/sample-buildout/parts/packages/pytz.egg',
'/sample-buildout/parts/packages/pkg_resources.py.egg',
'/sample-buildout/parts/packages/setuptools.egg',
'/sample-buildout/parts/packages/zc.egg',
]...

It is possible to disable zipping. And also to exclude or include
patterns of files. So for example we can strip down pytz. We can also
create a script.
patterns of files. So for example we can strip down the uneeded
setuptools egg. We can also create a script.

>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = %s
... develop = %(loc)s
... parts = packages test
... find-links = http://download.zope.org/distribution
... find-links = %(server)s
... index = %(server)s/index
...
... [packages]
... zip = False
... recipe = lovely.recipe:eggbox
... eggs = pytz
... eggs = demo
... lovely.recipe
... excludes = ^pytz/zoneinfo/Mexico/.*
... excludes = ^setuptools/.*
... ^easy_install.*
... ^pkg_resources.*
...
... [test]
... recipe = zc.recipe.egg:scripts
... eggs = lovely.recipe
... extra-paths = ${packages:path}
... interpreter = py
... """ % lovely_recipy_loc)
... """ % dict(loc=lovely_recipy_loc, server=link_server))
>>> print system(buildout),
Develop: '...'
Develop: '/Users/bd/sandbox/lovely.recipe'
Uninstalling packages.
Installing packages.
Generated script '/sample-buildout/bin/demo'.
Installing test.
Generated interpreter '/sample-buildout/bin/py'.

Expand All @@ -87,7 +108,8 @@ and we have set zipped to false, therefore it is only added to the
python path.

>>> ls(sample_buildout + '/parts/packages')
d pytz
d eggrecipedemo.py
d eggrecipedemoneeded.py
d zc

>>> print system(join(sample_buildout, 'bin', 'py') + \
Expand All @@ -96,31 +118,18 @@ python path.



>>> ls(sample_buildout + '/parts/packages/pytz/pytz/zoneinfo/Mexico')
Traceback (most recent call last):
...
OSError...No such file or directory: .../Mexico'

>>> ls(sample_buildout + '/parts/packages/pytz/pytz/zoneinfo/America')
- Adak
- Anchorage
- Anguilla
- ...

The test section uses the path of our packages section. Note that due,
to the development path of lovely.recipe this path is actually
included twice because the script recipe does not check duplicates.

>>> cat(sample_buildout + '/bin/py')
#!...
sys.path[0:0] = [
'/.../src',
'/Users/bd/.buildout/eggs/zc.recipe.egg-...egg',
'/sample-buildout/eggs/zc.buildout-...egg',
'/opt/local/lib/python2.5/site-packages',
'/.../src',
'/sample-buildout/parts/packages/pytz',
'/...lovely.recipe/src',
...
'/.../lovely.recipe/src',
'/sample-buildout/parts/packages/eggrecipedemo.py',
'/sample-buildout/parts/packages/eggrecipedemoneeded.py',
'/sample-buildout/parts/packages/zc',
]...


4 changes: 2 additions & 2 deletions src/lovely/recipe/egg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ def _mk_scripts(self, reqs, working_set, executable, dest,
continue
else:
sname = name

sname = os.path.join(dest, sname)
spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths)
generated.extend(
_script(module_name, attrs, path, sname, executable, arguments,
initialization)
initialization, rpsetup)
)
if interpreter:
sname = os.path.join(dest, interpreter)
Expand Down
6 changes: 5 additions & 1 deletion src/lovely/recipe/egg/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
from zope.testing import doctest, renormalizing

from lovely.recipe.testing import setUpBuildout
import zc.buildout.tests

def setUp(test):
setUpBuildout(test)
zc.buildout.tests.easy_install_SetUp(test)

def test_suite():

return unittest.TestSuite((
doctest.DocFileSuite(
'README.txt',
setUp=setUpBuildout,
setUp=setUp,
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
tearDown=testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
Expand Down
2 changes: 1 addition & 1 deletion src/lovely/recipe/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ def setUpBuildout(test):
testing.buildoutSetUp(test)
testing.install_develop('zc.recipe.egg', test)
testing.install_develop('lovely.recipe', test)
testing.install_develop('pytz', test)
testing.install_develop('zope.testing', test)
testing.install_develop('zope.interface', test)

0 comments on commit 6c6aac5

Please sign in to comment.