Skip to content

Instantly share code, notes, and snippets.

@GA-MEB
Last active July 4, 2016 04:01
Show Gist options
  • Save GA-MEB/4c583031b55a1704b7960fee4928608b to your computer and use it in GitHub Desktop.
Save GA-MEB/4c583031b55a1704b7960fee4928608b to your computer and use it in GitHub Desktop.
Python Setup
  1. brew install pyenv
  2. Open ~/.bashrc (or .bash_profile, on Linux) and add the following between the stuff for Rbenv and Git:
# Pyenv
export PYENV_ROOT=/usr/local/var/pyenv
eval "$(pyenv init -)"
  1. pyenv install 3.5.1 (or other version)
  2. pyenv global 3.5.1 (this can be combined with the previous command as pyenv install 3.5.1 && global 3.5.1)
  3. Python doesn't ship with the most up to date version of package manager pip, so upgrade pip : pip install -U pip
  4. Install pyenv-virtualenv, a tool that creates a named directory of executable dependencies and makes that directory available at the global level. Think of it this way:
  • With Ruby and Bundler, bundle install install all gems listed in the Gemfile into a global bucket (technically, subdivided by version of Ruby) which is then accessible to all projects; running bundle exec ensures that you execute the right versions of those dependencies for any given project.
  • With Node and NPM, npm install installs all Node moules listed in package.json into a local node_modules directory; since there's a separate node_modules folder inside each project, all executables are implicitly project-specific. However, this has the downside of downloading lots of copies of the same Node modules.
  • With pyeyv-virtualenv, you have a single global directory (bounded by Python version), just like Ruby; however, inside that global directory, you can create custom bundles of dependencies (i.e. 'virtual environments') and load a single bundle of dependencies inside multiple different projects. Kind of like lots of little node_modules directories, but with different names, and capable of being referenced by name and manually loaded.
  1. Install mamba and expects : pip install mamba expects

When you start a new python project, load up the appropriate requirements file (e.g. requirements-test.txt) by running pip install -r requirements-test.txt

To actually run your mamba tests, go to the root of your project repo and run mamba; it will look for a specs directory.

@gaand
Copy link

gaand commented May 8, 2016

I prefer to use my home directory for environment switching tools (NVM_DIR=/.nvm, RBENV_ROOT=/.rbenv, and now PYENV_ROOT=~/.pyenv). This makes it more platform independent (/usr/local is usually owned by root on a linux box). Your mileage may vary.

@gaand
Copy link

gaand commented May 8, 2016

I'm linking this from a new orientation issue, thus the comments.

Also, to assist developers in comprehending commands, prefer long options over short.

So this:

pip install --upgrade pip

rather than this:

pip install -U pip

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