Quick installation
==================

{{ DF_PROJECT_NAME }} mainly requires Python{% if available_python_versions %} ({{ available_python_versions|join:', ' }}){% endif %}{% if USE_CELERY %} and a Redis server for background tasks{% endif %}.

You should create a dedicated virtualenvironment on your system to isolate {{ DF_PROJECT_NAME }}.
You can use `pipenv <http://docs.python-guide.org/en/latest/dev/virtualenvs/>`_ or `virtualenvwrapper <https://virtualenvwrapper.readthedocs.io>`_.

For example, on Debian-based systems like Ubuntu:

.. code-block:: bash

{% block install_deps %}    sudo apt-get install {{ python_version }} {{ python_version }}-dev build-essential{% if USE_CELERY %} redis-server{% endif %}
{% block install_extra_deps %}{% endblock %}{% if pipeline.gem %}    sudo gem install {{ pipeline.gem|join:' ' }}
{% endif %}{% if pipeline.npm %}    sudo npm install -g {{ pipeline.npm|join:' ' }}
{% endif %}
{% if pipeline.other %}

{{ pipeline.other|join:', ' }} must also be installed.{% endif %}
{% endblock %}

{% block before_install %}{% endblock %}

If these requirements are fullfilled, then you can gon on and install {{ DF_PROJECT_NAME }}:

.. code-block:: bash

{% block application %}    pip install {{ DF_MODULE_NAME }} --user
{% endblock %}{% block pre_application %}{% endblock %}    {{ control_command }} collectstatic --noinput  # prepare static files (CSS, JS, …)
    {{ control_command }} migrate  # create the database (SQLite by default)
{% block post_application %}    {{ control_command }} createsuperuser  # create an admin user
    {{ control_command }} check  # everything should be ok
{% endblock %}
{% block after_install %}{% endblock %}
{% block before_basic_config %}{% endblock %}
{% block basic_config %}
You can easily change the root location for all data (SQLite database, uploaded or temp files, static files, …) by
editing the configuration file.

.. code-block:: bash

    CONFIG_FILENAME=`{{ control_command }} config ini -v 2 | grep -m 1 ' - .ini file' | cut -d '"' -f 2`
    # prepare a limited configuration file
    mkdir -p `dirname $CONFIG_FILENAME`
    cat << EOF > $CONFIG_FILENAME
    [global]
    data = $HOME/{{ DF_MODULE_NAME }}
    EOF

Of course, you must run again the `migrate` and `collectstatic` commands (or moving data to this new folder).
{% endblock %}
{% block after_basic_config %}{% endblock %}
{% block before_run_server %}{% endblock %}
{% block run_server %}
You can launch the server process{% if USE_CELERY %}es (the second process is required for background tasks){% endif %}:

.. code-block:: bash
{% block run_application %}
    {{ control_command }} server
{% if USE_CELERY %}    {{ control_command }} worker -Q {{ required_celery_queues|join:',' }}
{% endif %}{% endblock %}

Then open http://{{ LISTEN_ADDRESS }} with your favorite browser.
{% endblock %}
{% block after_run_server %}{% endblock %}

You can install {{ DF_PROJECT_NAME }} in your home (with the `--user` option), globally (without this option), or (preferably)
inside a virtualenv.
