Browse files

adding buildout installation for development

  • Loading branch information...
1 parent f11ebde commit 16019a5f13711cc54cbc006f42cf1a3ee84b3387 @Fantomas42 committed Mar 31, 2010
Showing with 254 additions and 0 deletions.
  1. +14 −0 .gitignore
  2. +121 −0 bootstrap.py
  3. +37 −0 buildout.cfg
  4. +78 −0 patches/NoseDjango-0.6.patch
  5. +4 −0 zinnia/testsettings.py
View
14 .gitignore
@@ -0,0 +1,14 @@
+*~
+*.pyc
+README.html
+bin
+lib
+dist
+eggs
+parts
+build
+include
+downloads
+develop-eggs
+.installed.cfg
+django_blog_zinnia.egg-info/
View
121 bootstrap.py
@@ -0,0 +1,121 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+from optparse import OptionParser
+
+tmpeggs = tempfile.mkdtemp()
+
+is_jython = sys.platform.startswith('java')
+
+# parsing arguments
+parser = OptionParser()
+parser.add_option("-v", "--version", dest="version",
+ help="use a specific zc.buildout version")
+parser.add_option("-d", "--distribute",
+ action="store_true", dest="distribute", default=False,
+ help="Use Distribute rather than Setuptools.")
+
+parser.add_option("-c", None, action="store", dest="config_file",
+ help=("Specify the path to the buildout configuration "
+ "file to be used."))
+
+options, args = parser.parse_args()
+
+# if -c was provided, we push it back into args for buildout' main function
+if options.config_file is not None:
+ args += ['-c', options.config_file]
+
+if options.version is not None:
+ VERSION = '==%s' % options.version
+else:
+ VERSION = ''
+
+USE_DISTRIBUTE = options.distribute
+args = args + ['bootstrap']
+
+to_reload = False
+try:
+ import pkg_resources
+ if not hasattr(pkg_resources, '_distribute'):
+ to_reload = True
+ raise ImportError
+except ImportError:
+ ez = {}
+ if USE_DISTRIBUTE:
+ exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
+ else:
+ exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+ if to_reload:
+ reload(pkg_resources)
+ else:
+ import pkg_resources
+
+if sys.platform == 'win32':
+ def quote(c):
+ if ' ' in c:
+ return '"%s"' % c # work around spawn lamosity on windows
+ else:
+ return c
+else:
+ def quote (c):
+ return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws = pkg_resources.working_set
+
+if USE_DISTRIBUTE:
+ requirement = 'distribute'
+else:
+ requirement = 'setuptools'
+
+if is_jython:
+ import subprocess
+
+ assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+ quote(tmpeggs), 'zc.buildout' + VERSION],
+ env=dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse(requirement)).location
+ ),
+ ).wait() == 0
+
+else:
+ assert os.spawnle(
+ os.P_WAIT, sys.executable, quote (sys.executable),
+ '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse(requirement)).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout' + VERSION)
+import zc.buildout.buildout
+zc.buildout.buildout.main(args)
+shutil.rmtree(tmpeggs)
View
37 buildout.cfg
@@ -0,0 +1,37 @@
+[buildout]
+parts = django
+ test
+ patch-nosedjango
+develop = .
+eggs = django-blog-zinnia
+ django-tagging
+ akismet
+ nose
+ NoseDjango
+ rednose
+
+find-links = http://dist.repoze.org/
+
+[django]
+recipe = djangorecipe
+version = 1.1.1
+projectegg = zinnia
+settings = testsettings
+eggs = ${buildout:eggs}
+
+[test]
+recipe = pbp.recipe.noserunner
+eggs = ${buildout:eggs}
+extra-paths = ${django:location}
+defaults = --rednose
+ --with-django
+environment = testenv
+
+[testenv]
+DJANGO_SETTINGS_MODULE = zinnia.testsettings
+
+[patch-nosedjango]
+recipe = collective.recipe.patch
+egg = NoseDjango
+patches = patches/NoseDjango-0.6.patch
+
View
78 patches/NoseDjango-0.6.patch
@@ -0,0 +1,78 @@
+--- nosedjango/nosedjango.py 2009-10-06 17:29:21.000000000 +0200
++++ nosedjango/nosedjango.py 2009-09-22 17:43:24.000000000 +0200
+@@ -14,7 +14,10 @@
+ # search the current working directory and all parent directories to find
+ # the settings file
+ from nose.importer import add_path
+-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
++
++if 'DJANGO_SETTINGS_MODULE' not in os.environ:
++ os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
++
+ import re
+ NT_ROOT = re.compile(r"^[a-zA-Z]:\\$")
+ def get_SETTINGS_PATH():
+@@ -66,20 +69,24 @@
+ if not SETTINGS_PATH:
+ sys.stderr.write("Can't find Django settings file!\n")
+ # short circuit if no settings file can be found
+- return
++ #return
+
+ if self.conf.addPaths:
+ map(add_path, self.conf.where)
+
+ add_path(SETTINGS_PATH)
+ sys.path.append(SETTINGS_PATH)
+- import settings
++
++ # use dynamical import: we not necessary use settings.py like settings
++ # file
++ __import__(os.environ['DJANGO_SETTINGS_MODULE'])
++ settings = sys.modules[os.environ['DJANGO_SETTINGS_MODULE']]
+
+ # Some Django code paths evaluate differently
+ # between DEBUG and not DEBUG. Example of this include the url
+ # dispatcher when 404's are hit. Django's own test runner forces DEBUG
+ # to be off.
+- settings.DEBUG = False
++ settings.DEBUG = False
+
+ from django.core import mail
+ self.mail = mail
+@@ -95,7 +102,7 @@
+ connection.creation.create_test_db(verbosity=self.verbosity)
+
+ # exit the setup phase and let nose do it's thing
+-
++
+ def beforeTest(self, test):
+
+ if not SETTINGS_PATH:
+@@ -104,7 +111,7 @@
+
+ # This is a distinctive difference between the NoseDjango
+ # test runner compared to the plain Django test runner.
+- # Django uses the standard unittest framework and resets the
++ # Django uses the standard unittest framework and resets the
+ # database between each test *suite*. That usually resolves
+ # into a test module.
+ #
+@@ -122,7 +129,7 @@
+ hasattr(test.context, 'fixtures'):
+ # We have to use this slightly awkward syntax due to the fact
+ # that we're using *args and **kwargs together.
+- call_command('loaddata', *test.context.fixtures, **{'verbosity': 0})
++ call_command('loaddata', *test.context.fixtures, **{'verbosity': 0})
+
+ if isinstance(test, nose.case.Test) and \
+ isinstance(test.test, nose.case.MethodTestCase) and \
+@@ -146,7 +153,7 @@
+ from django.test.utils import teardown_test_environment
+ from django.db import connection
+ from django.conf import settings
+- connection.creation.destroy_test_db(self.old_db, verbosity=self.verbosity)
++ connection.creation.destroy_test_db(self.old_db, verbosity=self.verbosity)
+ teardown_test_environment()
+
+ if hasattr(self, 'old_urlconf'):
View
4 zinnia/testsettings.py
@@ -0,0 +1,4 @@
+"""Settings for testing zinnia"""
+
+DATABASE_ENGINE = 'sqlite3'
+INSTALLED_APPS = ['zinnia', 'tagging']

0 comments on commit 16019a5

Please sign in to comment.