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

Commit

Permalink
version bump, documentation, cleanup, fixes in eggbox, see changes.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
dobe committed Aug 27, 2009
1 parent c5f9154 commit 13e190d
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 125 deletions.
16 changes: 16 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
Changes for lovely.recipe
=========================

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

- removed unused dependencies in setup.py

- generate doc from readmes and use it as long_description in setup,
a doc.txt file is generated when setup.py gets executed. this
method is taken from zc.buildout's setup.py.

- lovely.recipe.eggbox does not copy contents of develop eggs anymore
if zip is off (better for development).

- fixed interpreter option in lovely.recipe.eggbox

- cleaned up test setup and imports

2009/06/18 1.0.0b5
==================

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

[test]
recipe = zc.recipe.testrunner
eggs = lovely.recipe[zope]
defaults = ['--auto-color']

[importchecker]
recipe = lovely.recipe:importchecker
path = src/lovely
28 changes: 25 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python
from setuptools import setup, find_packages
import os

entry_points = """
[zc.buildout]
mkdir = lovely.recipe.fs.mkdir:Mkdir
Expand All @@ -12,10 +14,31 @@
eggbox = lovely.recipe.egg:EggBox
"""

def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()

long_description=(
'Lovely Recipes\n'
'**************\n'
+ '\n' +
read('src', 'lovely', 'recipe', 'fs', 'README.txt')
+ '\n' +
read('src', 'lovely', 'recipe', 'egg', 'README.txt')
+ '\n' +
read('src', 'lovely', 'recipe', 'i18n', 'README.txt')
+ '\n' +
read('src', 'lovely', 'recipe', 'importchecker', 'README.txt')
+ '\n'
)

open('doc.txt', 'w').write(long_description)


setup (
name='lovely.recipe',
description = "set of helper recipies for zc.buildout",
version='1.0.0b5',
description = "Set of helper recipies for zc.buildout",
long_description = long_description,
version='1.0.0b6',
author = "Lovely Systems",
author_email = "office@lovelysystems.com",
license = "ZPL 2.1",
Expand All @@ -26,7 +49,6 @@
package_dir = {'':'src'},
namespace_packages = ['lovely', 'lovely.recipe'],
extras_require = dict(zope=[
'zope.app.locales',
'zope.error',
'zc.zope3recipes',
'zc.zodbrecipes',
Expand Down
76 changes: 56 additions & 20 deletions src/lovely/recipe/egg/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,44 @@ environments. The recipies path option is filled with the created path
so it can be referenced by other buildout sections which may want to
use the recipe.

>>> import os
>>> lovely_recipy_loc = os.path.dirname(os.path.dirname(os.path.dirname(
... os.path.dirname(os.path.dirname(__file__)))))

>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = %s
... parts = packages
... find-links = http://download.zope.org/distribution
...
... [packages]
... recipe = lovely.recipe:eggbox
... eggs = zope.dublincore
... zope.formlib
... pytz
... """)
>>> print system(buildout),
Getting...
Installing packages.
... eggs = pytz
... lovely.recipe
... interpreter = py
... """ % lovely_recipy_loc)

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


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')
- BTrees.egg
- RestrictedPython.egg...
- zope.egg
- lovely.egg
- pytz.egg
- zc.egg

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

>>> cat(sample_buildout + '/bin/py')
#!...
sys.path[0:0] = [
'/sample-buildout/parts/packages/lovely.egg',
'/sample-buildout/parts/packages/pytz.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
Expand All @@ -41,29 +56,46 @@ create a script.
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = %s
... parts = packages test
... find-links = http://download.zope.org/distribution
...
... [packages]
... zip = False
... recipe = lovely.recipe:eggbox
... eggs = pytz
... lovely.recipe
... excludes = ^pytz/zoneinfo/Mexico/.*
...
... [test]
... recipe = zc.recipe.egg:scripts
... eggs = lovely.recipe
... extra-paths = ${packages:path}
... interpreter = py
... """)
... """ % lovely_recipy_loc)
>>> print system(buildout),
Develop: '...'
Uninstalling packages.
Installing packages.
Installing test.
Generated interpreter '/sample-buildout/bin/py'.

Note that we still have the same directory structure as the zipped
version with a directory for each top-level namespace. The 'lovely'
directory is not in he packages directory because it is a develop egg
and we have set zipped to false, therefore it is only added to the
python path.

>>> ls(sample_buildout + '/parts/packages')
d pytz
d zc

>>> print system(join(sample_buildout, 'bin', 'py') + \
... ' -c "import lovely.recipe; print lovely.recipe.__file__"')
/.../src/lovely/recipe/__init__.py...



>>> ls(sample_buildout + '/parts/packages/pytz/pytz/zoneinfo/Mexico')
Traceback (most recent call last):
...
Expand All @@ -75,16 +107,20 @@ create a script.
- Anguilla
- ...

Note that we still have the same directory structure as the zipped
version with a directory for each top-level namespace.


The test section uses the path of our packages section.
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')
#!...
import sys
<BLANKLINE>
sys.path[0:0] = [.../sample-buildout/parts/packages/pytz',
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',
'/sample-buildout/parts/packages/zc',
]...


31 changes: 25 additions & 6 deletions src/lovely/recipe/egg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import logging, os
import zc.recipe.egg
import shutil
import re
import shutil

import pkg_resources
from zc.buildout.easy_install import _script

import zc.recipe.egg
from zc.buildout.easy_install import _script, _pyscript, _relative_path_and_setup


log = logging.getLogger(__name__)

Expand All @@ -20,17 +23,27 @@ class EggBox(zc.recipe.egg.Scripts):
def __init__(self, buildout, name, options):
options['parts-directory'] = buildout['buildout']['parts-directory']
super(EggBox, self).__init__(buildout, name, options)

develop = self.buildout['buildout'].get('develop', [])
self.develop_paths = []
if develop:
for setup in develop.split():
self.develop_paths.append(
os.path.normpath(self.buildout._buildout_path(setup)))

# we need to do this on init because the signature cannot be
# created if the egg is not already there
self.ws = self.working_set()[1]
self.zip = self.options.get('zip') != 'False'

self.location = self.options.get(
'location',
os.path.join(self.options['parts-directory'], self.name))
if options.get('includes'):
self.includes += map(re.compile, options.get('includes').strip().split())
if options.get('excludes'):
self.excludes += map(re.compile, options.get('excludes').strip().split())

self._mk_zips()

def progress_filter(self, packages):
Expand Down Expand Up @@ -85,9 +98,13 @@ def _mk_zips(self):
shutil.rmtree(self.location)
os.mkdir(self.location)
dsts = []
path = []
for src, names in self.ws.entry_keys.items():
if self.src_exclude.match(src):
continue
if not self.zip and filter(src.startswith, self.develop_paths):
path.append(src)
continue
log.debug("Adding archive %r %r" % (src, names))
archive_util.unpack_archive(
src, self.location, progress_filter=self.progress_filter(names))
Expand All @@ -114,7 +131,6 @@ def _mk_zips(self):
z = os.path.join(self.location, name + '.egg')
make_zipfile(z, d)
shutil.rmtree(d)
path = []
for name in os.listdir(self.location):
path.append(os.path.join(self.location, name))
self.options['path'] = '\n'.join(path)
Expand All @@ -126,7 +142,10 @@ def _mk_scripts(self, reqs, working_set, executable, dest,
arguments='',
interpreter=None,
initialization='',
relative_paths=False,
):

path = [dist.location for dist in working_set]
path = list(self.path)
path.extend(extra_paths)
path = repr(path)[1:-1].replace(', ', ',\n ')
Expand Down Expand Up @@ -166,9 +185,9 @@ def _mk_scripts(self, reqs, working_set, executable, dest,
_script(module_name, attrs, path, sname, executable, arguments,
initialization)
)

if interpreter:
sname = os.path.join(dest, interpreter)
generated.extend(_pyscript(path, sname, executable))
spath, rpsetup = _relative_path_and_setup(sname, path, relative_paths)
generated.extend(_pyscript(path, sname, executable, rpsetup))

return generated
11 changes: 7 additions & 4 deletions src/lovely/recipe/i18n/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@
"""
__docformat__ = 'restructuredtext'

from zc.buildout import testing
import doctest, unittest
import unittest
from zope.testing import doctest, renormalizing

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

def setUp(test):
setUpBuildout(test)
testing.install_develop('zope.app.locales', test)
testing.install_develop('zope.i18nmessageid', test)

def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('README.txt',
setUp=setUpBuildout,
setUp=setUp,
tearDown=testing.buildoutTearDown,
optionflags=doctest.ELLIPSIS,
checker=renormalizing.RENormalizing([
Expand Down
10 changes: 5 additions & 5 deletions src/lovely/recipe/importchecker/README.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
=================
i18n Tools Recipe
=================
====================
Importchecker Recipe
====================

This recipe creates an importchecker instance in the bin directory.


Creating The Tools
==================
Creating The Script
===================

>>> write(sample_buildout, 'buildout.cfg',
... """
Expand Down
1 change: 0 additions & 1 deletion src/lovely/recipe/importchecker/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""
__docformat__ = 'restructuredtext'

import os
import logging

import zc.buildout
Expand Down
Loading

0 comments on commit 13e190d

Please sign in to comment.