diff --git a/.gitignore b/.gitignore index a55e31391b9..0ec1c1f08a8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ build.py **-all.js **-min.js media/uploads +vendor diff --git a/configs/sphinx/localsettings_django.py b/configs/sphinx/localsettings_django.py index 0c5520dd60a..590b91553cb 100644 --- a/configs/sphinx/localsettings_django.py +++ b/configs/sphinx/localsettings_django.py @@ -5,9 +5,11 @@ os.path.join(os.path.dirname(__file__), os.path.sep.join(('..',)*2))) sys.path.append(SETTINGS_DIR) -sys.path.append(os.path.join(SETTINGS_DIR,'lib')) -import settings_local as settings +# manage adds /apps, /lib and /vendor to the Python path. +import manage + +from django.conf import settings s = settings.DATABASES['default'] MYSQL_PASS = s['PASSWORD'] diff --git a/manage.py b/manage.py index 76be661e016..9616838434d 100755 --- a/manage.py +++ b/manage.py @@ -1,15 +1,28 @@ #!/usr/bin/env python import os import site - -from django.core.management import execute_manager, setup_environ +import sys ROOT = os.path.dirname(os.path.abspath(__file__)) path = lambda *a: os.path.join(ROOT, *a) +prev_sys_path = list(sys.path) + site.addsitedir(path('apps')) site.addsitedir(path('lib')) +site.addsitedir(path('vendor')) + +# Move the new items to the front of sys.path. +new_sys_path = [] +for item in list(sys.path): + if item not in prev_sys_path: + new_sys_path.append(item) + sys.path.remove(item) +sys.path[:0] = new_sys_path + +# Now we can import from third-party libraries. +from django.core.management import execute_manager, setup_environ try: import settings_local as settings diff --git a/requirements/compiled.txt b/requirements/compiled.txt new file mode 100644 index 00000000000..b700bd560e1 --- /dev/null +++ b/requirements/compiled.txt @@ -0,0 +1,4 @@ +MySQL-python==1.2.3c1 +Jinja2==2.2.1 +PIL==1.1.7 +lxml==2.2.6 diff --git a/requirements-dev.txt b/requirements/dev.txt similarity index 96% rename from requirements-dev.txt rename to requirements/dev.txt index adb585798d5..621dfed1af8 100644 --- a/requirements-dev.txt +++ b/requirements/dev.txt @@ -1,22 +1,21 @@ # # This pulls in requirements specific for development. --r requirements.txt +-r prod.txt --e git://github.com/jbalogh/check.git@1c73813fcd085020decc6f72caf232f71150db0a#egg=check --e git://github.com/robhudson/django-debug-toolbar.git@d05dcbb4aa93b1ce9d097ed8d537f06eb2491f5e#egg=django_debug_toolbar --e git://github.com/jbalogh/django-debug-cache-panel@dbdffc6048bde9e551f9bc01975ad3373b9c9427#egg=cache_panel +Werkzeug==0.5.1 ipython==0.10 sqlparse==0.1.1 - --e git://github.com/jbalogh/django-nose.git@70de9dd19e40bd292cdac06c51b6bfe703731504#egg=django_nose --e git://github.com/jbalogh/test-utils.git@c4c31905a95e59dcc8919c1030b23848ad7fbca6#egg=test-utils nose==0.11.1 coverage==3.2b4 selenium==1.0.1 mock==0.6.0 pyquery==0.5 translate-toolkit==1.6.0 - pylint==0.20.0 +-e git://github.com/jbalogh/check.git@1c73813fcd085020decc6f72caf232f71150db0a#egg=check +-e git://github.com/robhudson/django-debug-toolbar.git@d05dcbb4aa93b1ce9d097ed8d537f06eb2491f5e#egg=django_debug_toolbar +-e git://github.com/jbalogh/django-debug-cache-panel@dbdffc6048bde9e551f9bc01975ad3373b9c9427#egg=cache_panel +-e git://github.com/jbalogh/django-nose.git@70de9dd19e40bd292cdac06c51b6bfe703731504#egg=django_nose +-e git://github.com/jbalogh/test-utils.git@c4c31905a95e59dcc8919c1030b23848ad7fbca6#egg=test-utils diff --git a/requirements.txt b/requirements/prod.txt similarity index 85% rename from requirements.txt rename to requirements/prod.txt index 18d5e5e312e..6ffd5d5cc5a 100644 --- a/requirements.txt +++ b/requirements/prod.txt @@ -1,38 +1,23 @@ -e svn+http://code.djangoproject.com/svn/django/trunk@13302#egg=Django + +GitPython==0.1.7 +python-memcached==1.45 +Babel>=0.9.4 +celery==1.0.6 +python-dateutil +django-taggit==0.8.0 +pytz + -e git://github.com/jbalogh/django-multidb-router.git@25ca0c68929144ed9020d89f2ea1e941c7f9aeca#egg=django-multidb-router -e git://github.com/jbalogh/django-cache-machine.git#egg=django-cache-machine -e git://github.com/django-extensions/django-extensions.git#egg=django_extensions -Jinja2==2.2.1 -e git://github.com/jbalogh/jingo.git#egg=jingo -e git://github.com/jsocol/jingo-minify.git#egg=jingo-minify -e git://github.com/jsocol/bleach.git#egg=bleach -e git://github.com/jbalogh/schematic.git#egg=schematic -e git://github.com/jsocol/django-cronjobs.git#egg=django_cronjobs -e git://github.com/fwenzel/django-mozilla-product-details#egg=django-mozilla-product-details - -GitPython==0.1.7 -MySQL-python==1.2.3c1 -python-memcached==1.45 -Werkzeug==0.5.1 -Babel>=0.9.4 -phpserialize==1.2 -South==0.7 -celery==1.0.6 -python-dateutil -PIL==1.1.7 - -# for l10n -e git://github.com/clouserw/tower.git#egg=tower - -# commonware, stuff we share -e git://github.com/jsocol/commonware.git#egg=commonware - -# timezone package used with babel -pytz - -# wiki markup parser -e git://github.com/pcraciunoiu/py-wikimarkup.git@8b19befb719526735d08f5a185cf7cd1a382e4ad#egg=py-wikimarkup - -e hg+http://bitbucket.org/danfairs/django-authority#egg=django_authority - -django-taggit==0.8.0 diff --git a/scripts/build.sh b/scripts/build.sh index 5ec7028bc20..f487a79a44b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -7,7 +7,7 @@ VENV=$WORKSPACE/venv echo "Starting build..." # Clean up after last time. -find . -name '*.pyc' | xargs rm +find . -name '*.pyc' -exec rm {} \; if [ ! -d "$VENV/bin" ]; then echo "No virtualenv found; making one..." @@ -16,7 +16,7 @@ fi source $VENV/bin/activate -pip install -qr requirements-dev.txt +pip install -qUr requirements/dev.txt python manage.py update_product_details diff --git a/wsgi/kitsune.wsgi b/wsgi/kitsune.wsgi index 0007ccd5638..1ca1fbc1322 100644 --- a/wsgi/kitsune.wsgi +++ b/wsgi/kitsune.wsgi @@ -1,58 +1,41 @@ import os import site +from datetime import datetime -# Add the kitsune dir to the python path so we can import manage which sets up -# other paths and settings. +# Remember when mod_wsgi loaded this file so we can track it in nagios. +wsgi_loaded = datetime.now() + +# Add the zamboni dir to the python path so we can import manage. wsgidir = os.path.dirname(__file__) site.addsitedir(os.path.abspath(os.path.join(wsgidir, '../'))) -# We let Apache tell us where to find site packages through the SITE variable -# in the wsgi environment. That means we can't import anything from django or -# kitsune until we're inside of a request, so the first time through will run -# basic imports and validates our models (which cascades to import -# .models). - - -class KitsuneApp: - - def __init__(self): - self.setup = False - - def __call__(self, env, start_response): - if not self.setup: - self.setup_app(env) - self.setup = True - return self.kitsune_app(env, start_response) - - def setup_app(self, env): - if 'SITE' in env: - site.addsitedir(env['SITE']) - - # manage adds the `apps` and `lib` directories to the path. - import manage - - import django.conf - import django.core.handlers.wsgi - import django.core.management - import django.utils - - # Do validate and activate translations like using - # `./manage.py runserver` - # http://blog.dscpl.com/au/2010/03/improved-wsgi-script-for-use-with.html - utility = django.core.management.ManagementUtility() - command = utility.fetch_command('runserver') - command.validate() - django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE) - - # This is what mod_wsgi runs. - self.wsgi_handler = django.core.handlers.wsgi.WSGIHandler() - - def kitsune_app(self, env, start_response): - if 'HTTP_X_ZEUS_DL_PT' in env: - env['SCRIPT_URL'] = env['SCRIPT_NAME'] = '' - return self.wsgi_handler(env, start_response) +# manage adds /apps, /lib, and /vendor to the Python path. +import manage + +import django.conf +import django.core.handlers.wsgi +import django.core.management +import django.utils + +# Do validate and activate translations like using `./manage.py runserver`. +# http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html +django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE) +utility = django.core.management.ManagementUtility() +command = utility.fetch_command('runserver') +command.validate() + +# This is what mod_wsgi runs. +django_app = django.core.handlers.wsgi.WSGIHandler() + +# Normally we could let WSGIHandler run directly, but while we're dark +# launching, we want to force the script name to be empty so we don't create +# any /z links through reverse. This fixes bug 554576. +def application(env, start_response): + if 'HTTP_X_ZEUS_DL_PT' in env: + env['SCRIPT_URL'] = env['SCRIPT_NAME'] = '' + env['wsgi.loaded'] = wsgi_loaded + return django_app(env, start_response) -application = KitsuneApp() # Uncomment this to figure out what's going on with the mod_wsgi environment. # def application(env, start_response):