# Path: fabgis/virtualenv.py
# @task
# def setup_venv(code_path, requirements_file='requirements.txt'):
#     """Initialise or update the virtual environment.
# 
#     It will also ensure build-essential is installed, though you may need to
#     install required dev library using your own script.
# 
#     :param code_path: Base directory under which the venv dir should be made.
#     :type code_path: str
# 
#     :param requirements_file: Name of the requirements file to use in the
#         base directory. Defaults to ``requirements.txt``. If you pass in None
#         no attempt will be made to install packages from a requirements file.
#     :type requirements_file: str
# 
#     To run e.g.::
# 
#         fab -H 192.168.1.1:2222 setup_venv
# 
#     """
#     setup_env()
#     fastprint(blue('Setting up virtual env in: \n%s\nusing\n%s' % (
#         code_path, requirements_file)))
#     require_packages(['python-virtualenv', 'build-essential'])
#     with cd(code_path):
#         # Ensure we have a venv set up
#         virtualenv('venv')
#         if requirements_file is not None:
#             run('venv/bin/pip install -r %s' % requirements_file)
#     fastprint(green('Virtualenv setup completed.'))


from fabric.api import task, run, cd
from fabric.contrib.files import exists
from .virtualenv import setup_venv
interfere with other node based installations on the system.
"""


@task
def setup_node(work_path, node_version=None, proxy_url=None):
    """Setup node in a nodeenv to avoid conflicts with other node apps.

    See https://pypi.python.org/pypi/nodeenv

    After installation, you will have two subdirectories in the work_path::

        venv     <-- python venv
        env      <-- node env

    :param work_path: Directory into which node should be installed.
    :type work_path: str

    :param node_version: A specific version of node if you need it. Some node
        apps require a specific version of node, so this option will allow you
        to specify which one to install. Example '0.10.26'.
    :type node_version: str

    :param proxy_url: Optional parameters to specify the url to use for your
        network proxy. It should be specified in the form:
        ``http://<host>:<port>``. The same proxy will be used for both http and
        https urls. If ommitted no proxy will be used.
    :type proxy_url: str
    """
    with cd(work_path):

# Path: fabgis/virtualenv.py
# @task
# def setup_venv(code_path, requirements_file='requirements.txt'):
#     """Initialise or update the virtual environment.
# 
#     It will also ensure build-essential is installed, though you may need to
#     install required dev library using your own script.
# 
#     :param code_path: Base directory under which the venv dir should be made.
#     :type code_path: str
# 
#     :param requirements_file: Name of the requirements file to use in the
#         base directory. Defaults to ``requirements.txt``. If you pass in None
#         no attempt will be made to install packages from a requirements file.
#     :type requirements_file: str
# 
#     To run e.g.::
# 
#         fab -H 192.168.1.1:2222 setup_venv
# 
#     """
#     setup_env()
#     fastprint(blue('Setting up virtual env in: \n%s\nusing\n%s' % (
#         code_path, requirements_file)))
#     require_packages(['python-virtualenv', 'build-essential'])
#     with cd(code_path):
#         # Ensure we have a venv set up
#         virtualenv('venv')
#         if requirements_file is not None:
#             run('venv/bin/pip install -r %s' % requirements_file)
#     fastprint(green('Virtualenv setup completed.'))


# Path: fabgis/node.py
from fabric.api import task, run, cd
from fabric.contrib.files import exists
from .virtualenv import setup_venv

interfere with other node based installations on the system.
"""


@task
def setup_node(work_path, node_version=None, proxy_url=None):
    """Setup node in a nodeenv to avoid conflicts with other node apps.

    See https://pypi.python.org/pypi/nodeenv

    After installation, you will have two subdirectories in the work_path::

        venv     <-- python venv
        env      <-- node env

    :param work_path: Directory into which node should be installed.
    :type work_path: str

    :param node_version: A specific version of node if you need it. Some node
        apps require a specific version of node, so this option will allow you
        to specify which one to install. Example '0.10.26'.
    :type node_version: str

    :param proxy_url: Optional parameters to specify the url to use for your
        network proxy. It should be specified in the form:
        ``http://<host>:<port>``. The same proxy will be used for both http and
        https urls. If ommitted no proxy will be used.
    :type proxy_url: str
    """
    with cd(work_path):

        setup_venv(code_path=work_path, requirements_file=None)