Skip to content

Instantly share code, notes, and snippets.

@pwalsh
Last active February 4, 2020 18:38
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pwalsh/6400130 to your computer and use it in GitHub Desktop.
Save pwalsh/6400130 to your computer and use it in GitHub Desktop.
A development environment configuration on Mac OS X using Homebrew for package management. The configuration supports web app development in Python and Node. Additionally, there are some dependencies for audio synthesis projects in Python and Clojure.

Mac OS X development environment

Homebrew [ http://brew.sh/ ]

It all begins with Homebrew. This setup uses Homebrew for almost everything, including things your Mac ships with, like Python.

Managing everything in Homebrew lets us use the most up-to-date packages available, and means we are not subject to any customizations, however small, Apple makes to their packaged software.

First, either install the latest version of Xcode, or, if you don't want the full bloat of Xcode, you can just install Apple's Command Line Tools standalone. Either way - just make sure you have Command Line Tools - Homebrew will tell you if you don't have it.

Then, get Homebrew.

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Homebrew-managed dependencies

Now we have Homebrew, let's build out our development environment.

First, always make sure that Homebrew is up-to-date.

brew update
brew upgrade

Python

brew install python --framework
# and, if you additionally want Python 3
brew install python3 --framework

Node.js

brew install node

Clojure

brew install leiningen

Code versioning & management

brew install git git-flow mercurial svn

Web development dependencies

A basic set of tools covering data storage, serving, and testing.

brew install redis postgresql mongodb nginx phantomjs casperjs

At some point in time around the time that postgres 9.3 came out, I had to make more changes for postgres to work. I think this was related to upgrading to a new version of postgres. I had to do this:

initdb /usr/local/var/postgres -E utf8

And below, I'm going to install Salt Stack, which is an awesome tool for server deployment and remote execution. Salt requires some system dependencies, so install these to use Salt.

brew install swig zeromq

Internationalization

I regularly do projects that require internationalization and localization. In one way or another, tools higher up in the chain all require gettext.

brew install gettext

Image processing

We need some libraries to work with images in python code.

brew install libjpg libpng

Emacs

I only use Emacs for audio synthesis programming with Clojure, using the emacs-live configuration.

brew install emacs

And then follow here for configuring Emacs Live: http://overtone.github.io/emacs-live/doc-installation.html

Audio and MIDI handling

These requirements should be ignored if you are not doing audio synthesis programming.

brew install jack portaudio portmidi libsndfile liblo

pip-managed dependencies

pip is a Python package manager, and it should be preferred to other ways of managing Python dependencies.

In general, each Python project should have its own virtual environment, and inside, its own particular dependencies. To support this, we do need to install a couple of Python packages globally.

Virtual environments

pip install virtualenv virtualenvwrapper

Now that virtualenv and virtualenvwrapper are installed with our global Python, the shell session needs to know about it.

Add the following to your User's .bash_profile.

# this goes in ~/.bash_profile
export PYTHONIOENCODING=utf-8
export WORKON_HOME="/Users/<YOUR_USERNAME>/code/environments"
export PROJECT_HOME="/Users/<YOUR_USERNAME>/code/projects"
source /usr/local/bin/virtualenvwrapper.sh
export PIP_VIRTUAL_ENV_BASE=$WORKON_HOME

Save those changes, and then to pick them up in your current shell seesion, you need to source the file.

source ~/.bash_profile

Now, we'll create some directories to support this virtualenv configuration.

mkdir ~/code
mkdir ~/code/projects
mkdir ~/code/environments

If you get any returned errors up to here, something is wrong with the virtualenv configuration.

Remote execution

It is sometimes useful to have some remote execution tools with our global Python.

I am currently using Fabric.

pip install fabric

iPython

Interactive Python is also nice. Even though I don't really use it much for web development, I like to have it around, as I hope to give iPython Notebooks a try to data analysis projects one day.

pip install ipython

npm-managed dependencies

npm is the node package manager.

LESS

Less is a CSS pre-compiler. I think it is amazing.

npm install -g less

Package management

Using npm, a package manager, to install other package managers.

npm install -g volo bower

Compilers

npm -g install closurecompiler uglify-js

Other software

Google Cloud SDK

https://developers.google.com/cloud/sdk/

Vagrant

Vagrant is for configuring whole development environments, OS and all, for development and production.

http://www.vagrantup.com/

Once Vagrant is running on your system, install the Salt plugin for Vagrant.

vagrant plugin install vagrant-salt

Virtual Box

Vagrant uses Virtual Box.

https://www.virtualbox.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment