If you haven't already installed Homebrew (the brew
command), go ahead and do that now: https://brew.sh/
If you follow these instructions, check in with the TAs to let us know if they do/don't work!
I'm going to give instructions for Ubuntu 16.06.
First update your package repository:
$ apt-get update
Then install a few packages:
$ apt-get install -y git zsh make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev tree jq
You should be good to go! Skip ahead to the Python
installation instructions below.
If you follow these instructions, check in with the TAs to let us know if they do/don't work!
If you are on Windows 10 and you don't already have the Linux subsystem installed on your computer, go ahead and follow the instructions here: Install the Windows Subsystem for Linux
If you are not on Windows 10, you are going to want to just use Vagrant. There are some instructions here, from a previous offering of CMSC389L that used Vagrant.
Once you have the Ubuntu app installed, you'll likely need to create a new non-root user that you will login as. Check out these instructions.
From here, you can just follow the Linux instructions above.
We will use pyenv
to manage various versions of Python installed locally. For example, macOS comes with a pre-installed (usually outdated) version of Python. We'll be using Python 3.6.2.
First, install pyenv
:
$ curl -sL https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
Next, add the following lines to your ~/.bashrc
:
If you use Terminal.app on macOS: Edit
~/.bash_profile
instead as Terminal opens a login shell for every new terminal window. Though you should consider just moving over to iTerm2.
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Then, load those changes from your .bashrc
and verify that pyenv
is functioning:
$ source ~/.bashrc
$ pyenv versions
Now, go ahead and install Python:
$ pyenv install 3.6.2
$ pyenv global 3.6.2
You can check that this worked by running:
$ python --version
Note that whenever you run Python, it will now use this version as the default. However, you can also set a directory-local version using the pyenv local <python version>
command.
You will also be using pipenv
to manage pip packages.
If you are on macOS, run the following:
$ brew install pipenv
Otherwise, run the following:
$ pip install pipenv
To verify the installation, run:
$ pipenv --version
pipenv
introduces a Pipfile
. It's a deterministic version of requirement.txt
.
Most codelabs will ship with a Pipfile
. You can install the specified packages via:
$ pipenv install
This creates a local environment for you with all of the packages you need already installed.
To access this environment, run:
$ pipenv shell
That's it!
If you want to install other packages (like python-magic
), just run:
$ pipenv install python-magic
Normally in Python, you use a requirements.txt
file to track your project's dependencies. (An example from aws-cli
) You would run pip install -r requirements.txt
to install all dependencies. Easy enough.
However, this doesn't work well when you have multiple Python projects on your system. Some of those packages may collide: for example, possibly you want version 1.4.3
of package-a
for Project 1, but version 1.5.0
for Project 2. You'd have to pick!
Other package managers solve this by storing your dependencies in the same directory as your project. For example, Node's package manager, npm
, uses a node_modules
folder and your packages are accessed from that. Therefore, every package can have its own versions of packages.
In Python, the alternative is to use virtualenv
. This does something similar to npm
in that it creates a local environment for every Python project. Once you "activate" that local environment, you can then install your Python packages normally.
This separates global state from local state and is quite important in setting up a good development environment.
However, managing virtualenv
can be a pain. It's easy to accidentally forget to activate your environment and accidentally install all of your packages into your global Python environment (not great).
Thus, pipenv
. Among other features, it manages a virtualenv environment for each pipenv
shell, and locks down the set of dependencies required for that environment.
You will also need to set up the AWS CLI. To install the CLI:
$ pip install awscli
$ aws --version
Now, set up your default region and your AWS credentials by running:
$ aws configure
In the previous offering of this class, we had a few students accidentally commit their AWS credentials to a public GitHub. A variety of automatic scrapers by malicious folks are out there constantly checking GitHub for slip-ups like this.
So be careful about what you commit!!
Previous groups had hackers rack up $10k+ charges on their account (thankfully AWS support covered these charges for them).
If you make this mistake (it happens), change your access credentials and revert the commits. You can temporarily make that repo private in the meantime while you fix the git history.
Install the Docker Community Edition for your OS here: https://store.docker.com/search?offering=community&type=edition
note: certain adblockers, like ublock, may prevent you from seeing the downloadable versions. You can also find the community edition here
Double-check that it installed properly with docker version
.