Démarrage d'un nouveau projet
=============================
-* django-admin.py startproject <nom du projet> --template=
+* django-admin.py startproject <nom du projet> --name=django --template=
* (optionnel) configurer les versions de PYTHON au besoin dans :
- ./deploy.py
+ ./bin/deploy
./bin/django.wsgi
* git init
Déploiement du projet
=====================
-* python deploy.py
+* bin/deploy
Développement du projet
=======================
-* python deploy.py developments
+* bin/deploy development
-* python manage.py runserver --settings=settings.development
+* bin/django runserver --settings=settings.development
--- /dev/null
+#! /bin/bash
+
+ROOT_PATH=.
+if [ ! -e "$ROOT_PATH/README.rst" ]; then
+ echo "Placez vous à la racine du projet."
+ exit -1
+fi
+
+
+BUILD=$1
+if [ "$BUILD" = "" ]; then
+ BUILD='production'
+fi
+REQUIREMENTS=$ROOT_PATH/requirements/$BUILD.txt
+SETTINGS=settings.$BUILD
+
+
+VENV_PATH=$ROOT_PATH/.virtualenv
+if [ -e "$VENV_PATH" ]; then
+ echo "l'environnement virtuel existe déjà."
+else
+ echo "Création de l'environnement virtuel."
+ virtualenv --python=$PYTHON $VENV_PATH
+ rm -f distribute*.tar.gz
+fi
+
+echo "Activation de l'environnement virtuel."
+source $VENV_PATH/bin/activate
+which python
+
+
+echo "Installation des dépendances."
+pip install -r $REQUIREMENTS
+
+echo "Commandes Django"
+$ROOT_PATH/bin/django syncdb --settings=$SETTINGS --noinput
+$ROOT_PATH/bin/django migrate --settings=$SETTINGS --noinput
+$ROOT_PATH/bin/django collectstatic --settings=$SETTINGS --noinput
--- /dev/null
+#! .virtualenv/bin/python
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+
+ROOT_DIR = os.path.dirname((os.path.dirname(__file__)))
+VENV_DIR = os.path.join(ROOT_DIR, '.virtualenv')
+PROJECT_DIR = os.path.join(ROOT_DIR, '{{ project_name }}')
+
+sys.path.append(PROJECT_DIR)
+
+if __name__ == "__main__":
+ from django.core.management import execute_from_command_line
+ execute_from_command_line(sys.argv)
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import sys
-import os
-import subprocess
-from pkg_resources import parse_version
-
-PYTHON = "python2.6"
-ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
-VENV_DIR = os.path.join(ROOT_DIR, '.virtualenv')
-
-sys.path.append(os.path.join(ROOT_DIR, 'xxx'))
-
-
-def shell_exec(cmd):
- """
- Run blocked shell command.
- """
- print u"(*) %s" % cmd
- sp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
- sp.wait()
- out = sp.stdout.read().replace('\n', '')
- return out
-
-
-def setup_venv():
- """
- Virtualenv setup.
- """
- venv_version = shell_exec("virtualenv --version")
- venv_options = ["virtualenv", VENV_DIR, ]
-
- if parse_version(venv_version) >= parse_version('1.7'):
- venv_options.append("--system-site-packages", "--python=%s" % PYTHON)
- venv_create = " ".join(venv_options)
-
- if not os.path.exists(VENV_DIR):
- print u"VirtualEnv creation."
- shell_exec(venv_create)
- cleanup()
- else:
- print u"VirtualEnv already exists. Nothing to do."
-
-
-def setup_dependances(requirement_file):
- print u"Deps installation %s." % requirement_file
- shell_exec(
- "%s/bin/pip install -r %s" %
- (VENV_DIR, requirement_file)
- )
-
-
-def cleanup():
- """
- Do some cleanup stuff after setup.
- """
- for f in os.listdir(ROOT_DIR):
- if f.startswith('distribute'):
- os.remove(f)
-
-
-def setup_django(settings_module):
- print u"Run django commands with '%s' settings" % settings_module
- manage = "%s/bin/python manage.py" % VENV_DIR
- settings = "--settings=%s" % settings_module
- shell_exec("%s syncdb %s --noinput" % (manage, settings))
- shell_exec("%s migrate %s" % (manage, settings))
- shell_exec("%s collectstatic %s --noinput" % (manage, settings))
-
-
-if __name__ == "__main__":
-
- if len(sys.argv) > 1:
- requirement_file = 'requirements/%s.txt' % sys.argv[1]
- settings_module = 'settings.%s' % sys.argv[1]
- else:
- requirement_file = 'requirements/production.txt'
- settings_module = 'settings.production'
-
- setup_venv()
- setup_dependances(requirement_file)
- setup_django(settings_module)
- cleanup()
+++ /dev/null
-# -*- coding: utf-8 -*-
-
-import os
-import sys
-
-ROOT_DIR = os.path.dirname(__file__)
-VENV_DIR = os.path.join(ROOT_DIR, '.virtualenv')
-PROJECT_DIR = os.path.join(ROOT_DIR, '{{ project_name }}')
-
-sys.path.append(PROJECT_DIR)
-
-activate_this = os.path.join(VENV_DIR, 'bin/activate_this.py')
-execfile(activate_this, dict(__file__=activate_this))
-
-if __name__ == "__main__":
- from django.core.management import execute_from_command_line
- execute_from_command_line(sys.argv)