Package: django-deploy-setup
django-deploy=============Management command to automate deployment of django project usingdistutils/setuptools.TL;DR=====I used to define set of actions to be run after `git pull` to update my projectenvironment in various provisioning/deployment tools. However, since most ofthese actions were just `manage.py` commands and since I've started to use setupscript I wanted to define these actions right there.What this app does------------------Run sequence of management commands or any python callable right after projectapp is installed or updated. It's intended to be used with setup script, butcan be also run separately.What this app does not----------------------Restarts http server, database or other services. Although one can define taskswhich does one of these *root tasks*, this app isn't intended to do so. It'sleft to other provisioning/deployment tools like Fabric, Salt or Ansible.Usage=====1. Install `django-deploy-setup` and add it into your requirements.2. Add `django_deploy` to your INSTALLED_APPS.3. Next step depends whether your project uses `setup.py` or not:With ``setup.py``-----------------Add custom install command to `cmdclass` argument in your setup.py:```pythonfrom django_deploy.setup import DjangoInstall as installsetup(...cmdclass={'install': install},)````DjangoInstall` will call `deploy` management command after regular install.*Please note:* `DJANGO_SETTINGS_MODULE` environment variable must be definedbefore running `python setup.py install` when using `DjangoInstall` command.### Problem with `install_requires`This approach has one major flaw. In case you specify yourproject requirements using `install_requires` keyword, you won't be able toimport `django_deploy` module during initial install.One possible solution is add following import statement and installapplication twice. Updates will work just fine:```pythontry:from django_deploy.setup import DjangoInstall as installexcept ImportError:from distutils.command.install import install```Without ``setup.py``--------------------Simply call `manage.py deploy` after updating codebase andinstalling requirements.Default deployment tasks========================By default, `deploy` command will run following commands:1. `syncdb` (if you're using Django < 1.7)2. `migrate` (if your're using south or Django > 1.7)3. `collectstatic` (if you're using `django.contrib.staticfiles`)4. `compilemessages` (if you're using internationalization, `I18N = True`)Custom deployment tasks=======================If you want to run custom deployment tasks, create `deploy.py` file somewherein your project directory and set `DEPLOY_TASKS` in settings as dotted path:```pythonDEPLOY_TASKS = 'project_name.deploy````Next, create variable `tasks` as a list of `Task` instances:```python# project_name/deploy.pytasks = (Task('syncdb', interactive=False),Task('collectstatic', interactive=False),Task('compilemessages'),Task('custom_management_command'),)```Task definition---------------To define task simply pass command_name, args and kwargs as you would for`django.core.management.call_command`.```pythonTask('syncdb', interactive=False)```is the same as:```pythoncall_command('syncdb', interactive=False)```The difference is, that command defined via `Task` is executed using`run` method.Custom callable---------------If you want to use custom callable instead of default ``call_command``, pass``custom_callable`` keyword argument:```pythonTask(custom_callable=my_command, kwarg=42)```Licence=======MIT