From aefc00ea3b96e9fc9cc9ec95b3e9cf82bbd39c34 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 21:40:57 +0200 Subject: [PATCH 01/14] Upgraded versions and added coveralls --- .travis.yml | 16 ++++++++-------- bootstrap.py | 51 ++++++++++++++++++++++++++++++++++++--------------- buildout.cfg | 24 ++++-------------------- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index f2f6b77..63a4544 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,17 @@ language: python +sudo: false python: - - 2.6 - 2.7 -before_install: - - sudo apt-get install python-psycopg2 -notifications: - irc: - channels: "irc.freenode.org#nens" - on_success: change - email: false +cache: + directories: + - eggs + - $HOME/.local install: - deactivate + - pip install --user psycopg2 - python bootstrap.py - bin/buildout script: - bin/test +after_success: + - bin/coveralls diff --git a/bootstrap.py b/bootstrap.py index a629566..a459921 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -25,7 +25,10 @@ from optparse import OptionParser -tmpeggs = tempfile.mkdtemp() +__version__ = '2015-07-01' +# See zc.buildout's changelog if this version is up to date. + +tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') usage = '''\ [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] @@ -40,8 +43,9 @@ ''' parser = OptionParser(usage=usage) -parser.add_option("-v", "--version", help="use a specific zc.buildout version") - +parser.add_option("--version", + action="store_true", default=False, + help=("Return bootstrap.py version.")) parser.add_option("-t", "--accept-buildout-test-releases", dest='accept_buildout_test_releases', action="store_true", default=False, @@ -59,25 +63,33 @@ parser.add_option("--allow-site-packages", action="store_true", default=False, help=("Let bootstrap.py use existing site packages")) +parser.add_option("--buildout-version", + help="Use a specific zc.buildout version") parser.add_option("--setuptools-version", - help="use a specific setuptools version") - + help="Use a specific setuptools version") +parser.add_option("--setuptools-to-dir", + help=("Allow for re-use of existing directory of " + "setuptools versions")) options, args = parser.parse_args() +if options.version: + print("bootstrap.py version %s" % __version__) + sys.exit(0) + ###################################################################### # load/install setuptools try: - if options.allow_site_packages: - import setuptools - import pkg_resources from urllib.request import urlopen except ImportError: from urllib2 import urlopen ez = {} -exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) +if os.path.exists('ez_setup.py'): + exec(open('ez_setup.py').read(), ez) +else: + exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) if not options.allow_site_packages: # ez_setup imports site, which adds site packages @@ -88,12 +100,19 @@ # We can't remove these reliably if hasattr(site, 'getsitepackages'): for sitepackage_path in site.getsitepackages(): - sys.path[:] = [x for x in sys.path if sitepackage_path not in x] + # Strip all site-packages directories from sys.path that + # are not sys.prefix; this is because on Windows + # sys.prefix is a site-package directory. + if sitepackage_path != sys.prefix: + sys.path[:] = [x for x in sys.path + if sitepackage_path not in x] setup_args = dict(to_dir=tmpeggs, download_delay=0) if options.setuptools_version is not None: setup_args['version'] = options.setuptools_version +if options.setuptools_to_dir is not None: + setup_args['to_dir'] = options.setuptools_to_dir ez['use_setuptools'](**setup_args) import setuptools @@ -110,7 +129,12 @@ ws = pkg_resources.working_set +setuptools_path = ws.find( + pkg_resources.Requirement.parse('setuptools')).location + +# Fix sys.path here as easy_install.pth added before PYTHONPATH cmd = [sys.executable, '-c', + 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + 'from setuptools.command.easy_install import main; main()', '-mZqNxd', tmpeggs] @@ -123,11 +147,8 @@ if find_links: cmd.extend(['-f', find_links]) -setuptools_path = ws.find( - pkg_resources.Requirement.parse('setuptools')).location - requirement = 'zc.buildout' -version = options.version +version = options.buildout_version if version is None and not options.accept_buildout_test_releases: # Figure out the most recent final version of zc.buildout. import setuptools.package_index @@ -167,7 +188,7 @@ def _final_version(parsed_version): cmd.append(requirement) import subprocess -if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: +if subprocess.call(cmd) != 0: raise Exception( "Failed to execute command:\n%s" % repr(cmd)[1:-1]) diff --git a/buildout.cfg b/buildout.cfg index 384944c..2d159f8 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -1,5 +1,6 @@ [buildout] -index = http://packages.lizardsystem.nl +index = https://packages.lizard.net +extends = https://packages.lizard.net/kgs/latest.cfg show-picked-versions = true socket-timeout = 1 find-links = @@ -19,24 +20,6 @@ eggs = nensskel = # Reported by buildout -cheetah = 2.4.4 -collective.recipe.omelette = 0.15 -coverage = 3.6 -distribute = 0.6.34 -markdown = 2.2.1 -mock = 1.0.1 -nose = 1.3.0 -paste = 1.7.5.1 -pastedeploy = 1.5.0 -pastescript = 1.7.5 -pbp.recipe.noserunner = 0.2.6 -pep8 = 1.4.2 -pkginfo = 0.9.1 -pyflakes = 0.6.1 -setuptools = 15.1 -zc.buildout = 2.3.1 -zc.recipe.egg = 2.0.1 -zest.releaser = 3.43 [omelette] @@ -54,11 +37,12 @@ eggs = pep8 pyflakes zest.releaser + coveralls [test] recipe = pbp.recipe.noserunner -eggs = ${buildout:eggs} +eggs = nensskel nensskel[test] defaults = From 4366a8cbd81643fef9e13fdb7a5d2278bf722e02 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 21:44:03 +0200 Subject: [PATCH 02/14] Pinning setuptools (something needs it at the most recent version) --- buildout.cfg | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/buildout.cfg b/buildout.cfg index 2d159f8..2e1cc50 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -18,8 +18,17 @@ eggs = [versions] # Specific pins nensskel = +setuptools = 18.3.1 # Reported by buildout +Cheetah = 2.4.4 +Markdown = 2.6.2 +Paste = 2.0.2 +PasteDeploy = 1.5.2 +PasteScript = 2.0.2 +coveralls = 1.0 +docopt = 0.6.2 +pbp.recipe.noserunner = 0.2.6 [omelette] From ea5a9670e6fea538dc52ab9ad59fcce1fd88562d Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 21:49:00 +0200 Subject: [PATCH 03/14] Using latest kgs so that we get a correctly working setuptools --- nensskel/templates/lizardsite/development.cfg_tmpl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/nensskel/templates/lizardsite/development.cfg_tmpl b/nensskel/templates/lizardsite/development.cfg_tmpl index 53f6148..5266381 100644 --- a/nensskel/templates/lizardsite/development.cfg_tmpl +++ b/nensskel/templates/lizardsite/development.cfg_tmpl @@ -1,7 +1,7 @@ [buildout] index = https://packages.lizard.net extends = - https://packages.lizard.net/kgs/3.1.30/versions.cfg + https://packages.lizard.net/kgs/latest.cfg server.cfg find-links = prefer-final = true @@ -27,14 +27,8 @@ eggs = [versions] -# Specific pins. We inherit lots of pins from the KGS, so if you add a -# development egg, you really need to un-pin it here. +# Specific pins. ${project} = -Django = 1.6.5 -gp.recipe.node = -raven = -zc.buildout = -zc.recipe.egg = # Reported by buildout. From 20013df2860e7b58fdcf44a23d731d2b8ebee150 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 21:53:31 +0200 Subject: [PATCH 04/14] cleanup --- nensskel/templates/djangoapp/buildout.cfg_tmpl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/nensskel/templates/djangoapp/buildout.cfg_tmpl b/nensskel/templates/djangoapp/buildout.cfg_tmpl index c8054db..d1dc537 100644 --- a/nensskel/templates/djangoapp/buildout.cfg_tmpl +++ b/nensskel/templates/djangoapp/buildout.cfg_tmpl @@ -24,13 +24,8 @@ eggs = [versions] -# Specific pins. We inherit lots of pins from the KGS, so if you add a -# development egg, you really need to un-pin it here. +# Specific pins. ${project} = -gp.recipe.node = -raven = -zc.buildout = -zc.recipe.egg = # Reported by buildout. From 7a5271a1beae677be1bb911748d13b00577589e2 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 21:54:10 +0200 Subject: [PATCH 05/14] Removed ancient pins --- nensskel/templates/library/buildout.cfg_tmpl | 3 --- 1 file changed, 3 deletions(-) diff --git a/nensskel/templates/library/buildout.cfg_tmpl b/nensskel/templates/library/buildout.cfg_tmpl index 431bd48..c437739 100644 --- a/nensskel/templates/library/buildout.cfg_tmpl +++ b/nensskel/templates/library/buildout.cfg_tmpl @@ -23,8 +23,6 @@ eggs = [versions] # Specific pins ${project} = -zc.buildout = 2.2.1 -zc.recipe.egg = 2.0.1 # Reported by buildout. @@ -32,7 +30,6 @@ zc.recipe.egg = 2.0.1 [sources] # Examples: # lizard-ui = git git@github.com:lizardsystem/nensskel.git -# lizard-ui = svn https://office.nelen-schuurmans.nl/svn/Products/djangoapps/lizard-ui/trunk # [sysegg] From a830ba84b100282adfb566a1224c0d2692d78f3a Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 21:55:58 +0200 Subject: [PATCH 06/14] Upgraded bootstrap version in the generated projects, too --- nensskel/templates/library/bootstrap.py | 51 +++++++++++++++++-------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/nensskel/templates/library/bootstrap.py b/nensskel/templates/library/bootstrap.py index a629566..a459921 100644 --- a/nensskel/templates/library/bootstrap.py +++ b/nensskel/templates/library/bootstrap.py @@ -25,7 +25,10 @@ from optparse import OptionParser -tmpeggs = tempfile.mkdtemp() +__version__ = '2015-07-01' +# See zc.buildout's changelog if this version is up to date. + +tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') usage = '''\ [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] @@ -40,8 +43,9 @@ ''' parser = OptionParser(usage=usage) -parser.add_option("-v", "--version", help="use a specific zc.buildout version") - +parser.add_option("--version", + action="store_true", default=False, + help=("Return bootstrap.py version.")) parser.add_option("-t", "--accept-buildout-test-releases", dest='accept_buildout_test_releases', action="store_true", default=False, @@ -59,25 +63,33 @@ parser.add_option("--allow-site-packages", action="store_true", default=False, help=("Let bootstrap.py use existing site packages")) +parser.add_option("--buildout-version", + help="Use a specific zc.buildout version") parser.add_option("--setuptools-version", - help="use a specific setuptools version") - + help="Use a specific setuptools version") +parser.add_option("--setuptools-to-dir", + help=("Allow for re-use of existing directory of " + "setuptools versions")) options, args = parser.parse_args() +if options.version: + print("bootstrap.py version %s" % __version__) + sys.exit(0) + ###################################################################### # load/install setuptools try: - if options.allow_site_packages: - import setuptools - import pkg_resources from urllib.request import urlopen except ImportError: from urllib2 import urlopen ez = {} -exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) +if os.path.exists('ez_setup.py'): + exec(open('ez_setup.py').read(), ez) +else: + exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) if not options.allow_site_packages: # ez_setup imports site, which adds site packages @@ -88,12 +100,19 @@ # We can't remove these reliably if hasattr(site, 'getsitepackages'): for sitepackage_path in site.getsitepackages(): - sys.path[:] = [x for x in sys.path if sitepackage_path not in x] + # Strip all site-packages directories from sys.path that + # are not sys.prefix; this is because on Windows + # sys.prefix is a site-package directory. + if sitepackage_path != sys.prefix: + sys.path[:] = [x for x in sys.path + if sitepackage_path not in x] setup_args = dict(to_dir=tmpeggs, download_delay=0) if options.setuptools_version is not None: setup_args['version'] = options.setuptools_version +if options.setuptools_to_dir is not None: + setup_args['to_dir'] = options.setuptools_to_dir ez['use_setuptools'](**setup_args) import setuptools @@ -110,7 +129,12 @@ ws = pkg_resources.working_set +setuptools_path = ws.find( + pkg_resources.Requirement.parse('setuptools')).location + +# Fix sys.path here as easy_install.pth added before PYTHONPATH cmd = [sys.executable, '-c', + 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + 'from setuptools.command.easy_install import main; main()', '-mZqNxd', tmpeggs] @@ -123,11 +147,8 @@ if find_links: cmd.extend(['-f', find_links]) -setuptools_path = ws.find( - pkg_resources.Requirement.parse('setuptools')).location - requirement = 'zc.buildout' -version = options.version +version = options.buildout_version if version is None and not options.accept_buildout_test_releases: # Figure out the most recent final version of zc.buildout. import setuptools.package_index @@ -167,7 +188,7 @@ def _final_version(parsed_version): cmd.append(requirement) import subprocess -if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: +if subprocess.call(cmd) != 0: raise Exception( "Failed to execute command:\n%s" % repr(cmd)[1:-1]) From 68ba0d0ab838527dd71572063fe5504ea2bfff53 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 22:03:34 +0200 Subject: [PATCH 07/14] Testing for bin/sphinx, a good test to make sure buildout really ran OK. This demonstrates that djangorecipe needs to be re-configured --- nensskel/smoketest.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nensskel/smoketest.rst b/nensskel/smoketest.rst index f444de2..cdbfc40 100644 --- a/nensskel/smoketest.rst +++ b/nensskel/smoketest.rst @@ -119,6 +119,8 @@ The python library: ... else: ... print "succeeded" succeeded + >>> 'sphinx' in os.listdir('bin') # One of the last being installed + True The lizard app: @@ -134,6 +136,8 @@ The lizard app: ... else: ... print "succeeded" succeeded + >>> 'sphinx' in os.listdir('bin') # One of the last being installed + True The lizard site: @@ -150,3 +154,5 @@ The lizard site: ... else: ... print "succeeded" succeeded + >>> 'sphinx' in os.listdir('bin') # One of the last being installed + True From 53efa5c617a0c0e6b48870dd7680a65cf3b55344 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 22:13:36 +0200 Subject: [PATCH 08/14] Improved the test so that issue #12 shows up. --- nensskel/smoketest.rst | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/nensskel/smoketest.rst b/nensskel/smoketest.rst index cdbfc40..26db814 100644 --- a/nensskel/smoketest.rst +++ b/nensskel/smoketest.rst @@ -113,14 +113,12 @@ The python library: Creating directory .../aaa/bin'. ... Generated script .../aaa/bin/buildout... - >>> output = system('bin/buildout -t 1') # '-t 1' is the socket timeout... - >>> if 'Traceback' in output: - ... print output - ... else: - ... print "succeeded" - succeeded - >>> 'sphinx' in os.listdir('bin') # One of the last being installed - True + >>> print 'start', system('bin/buildout') #doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + start... + Installing sphinx. + ... + +(We test for sphinx as that's the last part being installed). The lizard app: @@ -130,14 +128,10 @@ The lizard app: Creating directory .../li-zard/bin'. ... Generated script .../li-zard/bin/buildout... - >>> output = system('bin/buildout -t 1') # '-t 1' is the socket timeout... - >>> if 'Traceback' in output: - ... print output - ... else: - ... print "succeeded" - succeeded - >>> 'sphinx' in os.listdir('bin') # One of the last being installed - True + >>> print 'start', system('bin/buildout') #doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + start... + Installing sphinx. + ... The lizard site: @@ -148,11 +142,7 @@ The lizard site: Creating directory .../nieuwegein/bin'. ... Generated script .../nieuwegein/bin/buildout... - >>> output = system('bin/buildout -t 1') # '-t 1' is the socket timeout... - >>> if 'Traceback' in output: - ... print output - ... else: - ... print "succeeded" - succeeded - >>> 'sphinx' in os.listdir('bin') # One of the last being installed - True + >>> print 'start', system('bin/buildout') #doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + start... + Installing sphinx. + ... From c6040b0be70958001cc671dc8a12fa9b0415fe87 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 22:21:48 +0200 Subject: [PATCH 09/14] Fixes #12: removed deprecated djangorecipe options --- nensskel/templates/djangoapp/buildout.cfg_tmpl | 2 +- nensskel/templates/lizardsite/development.cfg_tmpl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nensskel/templates/djangoapp/buildout.cfg_tmpl b/nensskel/templates/djangoapp/buildout.cfg_tmpl index d1dc537..348c457 100644 --- a/nensskel/templates/djangoapp/buildout.cfg_tmpl +++ b/nensskel/templates/djangoapp/buildout.cfg_tmpl @@ -76,13 +76,13 @@ paths = # See http://jacobian.org/writing/django-apps-with-buildout/ recipe = djangorecipe project = ${package} -projectegg = ${package} settings = testsettings test = ${package} eggs = ${project} ${project}[test] + [omelette] # Creates a nice parts/omelette with our used eggs recipe = collective.recipe.omelette diff --git a/nensskel/templates/lizardsite/development.cfg_tmpl b/nensskel/templates/lizardsite/development.cfg_tmpl index 5266381..738b695 100644 --- a/nensskel/templates/lizardsite/development.cfg_tmpl +++ b/nensskel/templates/lizardsite/development.cfg_tmpl @@ -76,11 +76,11 @@ workers = 3 # Sets up django for testing our application. # See http://jacobian.org/writing/django-apps-with-buildout/ recipe = djangorecipe -wsgi = true -wsgilog = \${buildout:directory}/var/log/django.log project = ${package} -projectegg = ${package} settings = developmentsettings +scripts-with-settings = + gunicorn +# celery test = ${package} eggs = ${project} From 39b788efa8ff426de39facfe8464405d31530527 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 22:22:09 +0200 Subject: [PATCH 10/14] Newer way to run gunicorn-with-settings --- .../templates/lizardsite/+package+/wsgi.py_tmpl | 15 +++++++++++++++ nensskel/templates/lizardsite/server.cfg | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 nensskel/templates/lizardsite/+package+/wsgi.py_tmpl diff --git a/nensskel/templates/lizardsite/+package+/wsgi.py_tmpl b/nensskel/templates/lizardsite/+package+/wsgi.py_tmpl new file mode 100644 index 0000000..db10bd1 --- /dev/null +++ b/nensskel/templates/lizardsite/+package+/wsgi.py_tmpl @@ -0,0 +1,15 @@ +""" +WSGI config for the ${project} project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ +""" + +import os +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "${package}.developmentsettings") +# bin/gunicorn-with-settings sets the correct dev/staging/prod settings, btw. + +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() diff --git a/nensskel/templates/lizardsite/server.cfg b/nensskel/templates/lizardsite/server.cfg index 3073d31..c819b61 100644 --- a/nensskel/templates/lizardsite/server.cfg +++ b/nensskel/templates/lizardsite/server.cfg @@ -43,7 +43,7 @@ port = ${serverconfig:supervisor-port} user = sdfsdfsdf password = aosdifsdf programs = - 10 gunicorn ${buildout:bin-directory}/django [run_gunicorn 127.0.0.1:${serverconfig:gunicorn-port} --workers=${serverconfig:workers} --timeout 90 --preload --max-requests=${serverconfig:maxrequests}] + 10 gunicorn ${buildout:bin-directory}/gunicorn-with-settings [-b 127.0.0.1:${serverconfig:gunicorn-port} --workers=${serverconfig:workers} --timeout 90 --preload --max-requests=${serverconfig:maxrequests} ${package}.wsgi] [supervisor-cronjob] From 89bdf1a522ce1f37cef55ff06f7cc0675d82ab4b Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 22:27:54 +0200 Subject: [PATCH 11/14] Moved to a _tmpl so that $package works --- nensskel/templates/lizardsite/server.cfg_tmpl | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 nensskel/templates/lizardsite/server.cfg_tmpl diff --git a/nensskel/templates/lizardsite/server.cfg_tmpl b/nensskel/templates/lizardsite/server.cfg_tmpl new file mode 100644 index 0000000..3894695 --- /dev/null +++ b/nensskel/templates/lizardsite/server.cfg_tmpl @@ -0,0 +1,61 @@ +[buildout] +serverparts = + nginxconf + logrotateconf + supervisor + + +[serverconfig] +# Settings for supervisor, nginx and so. +# Override these in your buildout.cfg +gunicorn-port = todo +supervisor-port = todo +sitename = todo +workers = 5 +maxrequests = 500 + + +[nginxconf] +recipe = collective.recipe.template +input = \${buildout:directory}/etc/nginx.conf.in +output = \${buildout:directory}/etc/\${serverconfig:sitename}.nginx.conf + + +[logrotateconf] +# Log rotation for django.log. +# access.log and error.log have their own global logrotation. +# Supervisor also has its own build-in log rotation. +recipe = collective.recipe.template +input = \${buildout:directory}/etc/logrotate.conf.in +output = \${buildout:directory}/etc/\${serverconfig:sitename}.logrotate + + +[collectstatic] +recipe = iw.recipe.cmd +on_install = true +on_update = true +cmds = \${buildout:bin-directory}/django collectstatic --noinput + + +[supervisor] +recipe = collective.recipe.supervisor +port = \${serverconfig:supervisor-port} +user = sdfsdfsdf +password = aosdifsdf +programs = + 10 gunicorn \${buildout:bin-directory}/gunicorn-with-settings [-b 127.0.0.1:\${serverconfig:gunicorn-port} --workers=\${serverconfig:workers} --timeout 90 --preload --max-requests=\${serverconfig:maxrequests} ${package}.wsgi] + + +[supervisor-cronjob] +recipe = z3c.recipe.usercrontab +times = @reboot +command = \${buildout:bin-directory}/supervisord + + +[django-session-cleanup-cronjob] +# Cleans expired sessions from the database every night +# Note: "changed in Django 1.5: cleanup is deprecated. Use clearsessions instead." +# Note: ideally, should clean everything referencing the session_key as well +recipe = z3c.recipe.usercrontab +times = @daily +command = \${buildout:bin-directory}/django cleanup From bd5b85b3b7842c6e41731edbfe4648b55d5bfdbb Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 22:28:19 +0200 Subject: [PATCH 12/14] Moved server.cfg to a template --- nensskel/templates/lizardsite/server.cfg | 61 ------------------------ 1 file changed, 61 deletions(-) delete mode 100644 nensskel/templates/lizardsite/server.cfg diff --git a/nensskel/templates/lizardsite/server.cfg b/nensskel/templates/lizardsite/server.cfg deleted file mode 100644 index c819b61..0000000 --- a/nensskel/templates/lizardsite/server.cfg +++ /dev/null @@ -1,61 +0,0 @@ -[buildout] -serverparts = - nginxconf - logrotateconf - supervisor - - -[serverconfig] -# Settings for supervisor, nginx and so. -# Override these in your buildout.cfg -gunicorn-port = todo -supervisor-port = todo -sitename = todo -workers = 5 -maxrequests = 500 - - -[nginxconf] -recipe = collective.recipe.template -input = ${buildout:directory}/etc/nginx.conf.in -output = ${buildout:directory}/etc/${serverconfig:sitename}.nginx.conf - - -[logrotateconf] -# Log rotation for django.log. -# access.log and error.log have their own global logrotation. -# Supervisor also has its own build-in log rotation. -recipe = collective.recipe.template -input = ${buildout:directory}/etc/logrotate.conf.in -output = ${buildout:directory}/etc/${serverconfig:sitename}.logrotate - - -[collectstatic] -recipe = iw.recipe.cmd -on_install = true -on_update = true -cmds = ${buildout:bin-directory}/django collectstatic --noinput - - -[supervisor] -recipe = collective.recipe.supervisor -port = ${serverconfig:supervisor-port} -user = sdfsdfsdf -password = aosdifsdf -programs = - 10 gunicorn ${buildout:bin-directory}/gunicorn-with-settings [-b 127.0.0.1:${serverconfig:gunicorn-port} --workers=${serverconfig:workers} --timeout 90 --preload --max-requests=${serverconfig:maxrequests} ${package}.wsgi] - - -[supervisor-cronjob] -recipe = z3c.recipe.usercrontab -times = @reboot -command = ${buildout:bin-directory}/supervisord - - -[django-session-cleanup-cronjob] -# Cleans expired sessions from the database every night -# Note: "changed in Django 1.5: cleanup is deprecated. Use clearsessions instead." -# Note: ideally, should clean everything referencing the session_key as well -recipe = z3c.recipe.usercrontab -times = @daily -command = ${buildout:bin-directory}/django cleanup From 923b63189f357c46464b62adb1c39b7e7ffc171f Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 22:38:13 +0200 Subject: [PATCH 13/14] Updated changelog --- CHANGES.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 9e1c05b..bdf320b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,25 @@ Changelog for nensskel - Update packages mitigating the 'ValueError: too many values to unpack'. +- Updated versions, using new lizard5 KGS. You can just as well remove the + 'extends' line for your own projects, but at least for testing nensskel, I'm + keeping it in for now. + [reinout] + +- Fixed djangorecipe setup. Deprecated options have been removed (fixes + #12). + [reinout] + +- Using ``wsgi.py`` file and the new djangorecipe ``scripts-with-settings` + option: this fixes the gunicorn (and celery) setup for modern + django/gunicorn combinations. + [reinout] + +- Improved tests so that more buildout failures show up (like the necessary + djangorecipe changes from the previous point). The test setup now also + includes coverallls.io integration for coverage reports. + [reinout] + 1.35 (2015-01-21) ----------------- From 23ee8e95fc542628283244fde8759ea103af69f4 Mon Sep 17 00:00:00 2001 From: Reinout van Rees Date: Fri, 18 Sep 2015 22:42:00 +0200 Subject: [PATCH 14/14] cleaned up the readme --- README.rst | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/README.rst b/README.rst index 42c23c6..e15d42b 100644 --- a/README.rst +++ b/README.rst @@ -1,17 +1,21 @@ Django code skeletons ===================== +.. image:: https://travis-ci.org/lizardsystem/nensskel.svg?branch=master + :target: https://travis-ci.org/lizardsystem/nensskel + + +.. image:: https://coveralls.io/repos/lizardsystem/nensskel/badge.svg?branch=reinout-version-upgrades&service=github + :target: https://coveralls.io/github/lizardsystem/nensskel?branch=reinout-version-upgrades + + + ``nensskel`` provides so-called "paster templates" so you can easily create new Django applications, websites and python libraries. They're not fully generic, as they originated within one company (see below). -The nensskel script creates a directory structure for you with (some -partially filled) basic files (like a ``README.rst`` and a ``setup.py``). -Optionally you can use it to automatically create a trunk/tags/branches -structure in svn. - -.. image:: https://secure.travis-ci.org/lizardsystem/nensskel.png?branch=master - :target: http://travis-ci.org/#!/lizardsystem/nensskel +The nensskel script creates a directory structure for you with (some +partially filled) basic files (like a ``README.rst`` and a ``setup.py``). Call the nensskel script to get usage information. @@ -20,7 +24,7 @@ Installation is straightforward with easy_install:: $ easy_install nensskel or with pip:: - + $ pip install nensskel (Probably you need to run it with sudo on osx/linux). @@ -33,12 +37,13 @@ Don't forget to update from time to time:: Available templates ------------------- -* **basic_package:** A basic setuptools-enabled package -* **nens_djangoapp:** A buildout for nens Django applications +Three nens-specific templates are included: + * **nens_library:** A buildout for nens libraries + +* **nens_djangoapp:** A buildout for nens Django applications + * **nens_lizardsite:** A buildout for nens lizard Django sites -* **nens_leansite:** A buildout for nens Django sites (doesn't inherit from other templates) -* **paste_deploy:** A web application deployed through paste.deploy Company-centricity @@ -49,13 +54,15 @@ We set it up the way we like it and we change it the way we like it so it might not fit your case 100%. But it does provide a good example to give you a head start with a completely -setup Django application/site. For example, the Django sites come with a +setup Django application/site. For example, the Django sites come with a full-blown nginx config and Django-staticfiles is included for easy css/js setup. If the available templates don't serve your need, you can do two things: -1. Clone the repository and edit the template as you like; possibly submit a pull -request -2. Make your own template + +- Clone the repository and edit the template as you like; possibly submit a + pull request + +- Make your own template Drop us a line if you need help. @@ -67,7 +74,7 @@ Example for your own skeleton When you want to create your own skeleton, nensskel can be a nice, small example. Just download the .tar.gz and unpack it. -Do the regular ``python bootstrap.py && bin/buildout`` and you're good to go. +Do the regular ``python bootstrap.py && bin/buildout`` and you're good to go. The nensskel and paster scripts are created in the *bin/* directory. There is one python script in ``nensskel/*.py`` per template. The actual