Use Homebrew to install pyenv and pyenv-virtualenv:
$ brew install pyenv
$ brew install pyenv-virtualenvAdd the following to your ~/.bash_profile or equivalent shell initialization script:
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"Then source ~/.bash_profile and install the version of Python you need:
$ pyenv install 2.7.13
$ pyenv global 2.7.13To see a list of avaiable Python versions:
$ pyenv install --listTo create a Python environment specific to a project use the pyenv virtualenv command with the version of Python you want to use and the name of your virtual environment:
$ cd project-name
$ pyenv virtualenv 2.7.13 project-name
$ pyenv activate project-name
... you doing lots of work
$ pyenv deactivate
Add your dependency using pip install:
$ pip install fabricPython use requirements.txt to define a project's dependencies. You can use pip freeze to generate that file:
$ pip freeze > requirements.txt
$ git add requirements.txtTo install dependencies listed in requirements.txt use the pip install command:
$ pip install -r requirements.txtUse Fabric to automate tasks and deployments.
First add fabric with the pip install command:
$ pip install fabricCreate a file named fabfile.py and define Tasks in it:
from fabric.api import task
from fabric.operations import local
@task(alias='s', default=True)
def server():
"""Start a local web server on port 4567"""
local('python server.py')The local command is used to run tasks on your local machine.
To run a task use the fab command followed by the name of the task:
$ fab server
[localhost] local: python server.py
Serving HTTP on 0.0.0.0 port 4567 ...To list the tasks available in your Fabfile, use the --list or -l command-line option:
$ fab -l
Available commands:
s Start a local web server on port 4567
server Start a local web server on port 4567