Local Setup

These instructions will guide you through setting up your computer to develop web applications with Flask.

  1. Overview
  2. Creating Accounts
  3. Working in the Labs
  4. Windows Setup
  5. OS X Setup
  6. Linux Setup

Overview

This guide will walk you through setting up the following:

  1. A GitHub account to share your source code
  2. Git to version and share your source code
  3. Python 3.4 to run your web servers
  4. PyCharm to edit and develop your applications
  5. A Python virtual environment containing the libraries we will be using at the start of the semester
  6. (Optional) Firefox Developer Edition for testing and development
  7. (Optional) SourceTree for more advanced Git operations

Creating Accounts

In order to complete the course work, you will need accounts with the university's GitHub and JetBrains.

GitHub

Everyone already has a Texas State GitHub account that will automatically be activated as soon as you sign in. To activate yours, visit https://git.txstate.edu and log in with your NetID and password.

JetBrains

When you download PyCharm, it will automatically activate a 30-day demo. Since semesters are longer than 30 days, we'll need a way to have access to it beyond that.

JetBrains provdides free student licenses to PyCharm if you register with your Texas State e-mail address. Visit https://www.jetbrains.com/student/, click ‘Apply’, and follow their instructions. You should, at the end of them, have a JetBrains account and password that you can then use to log in to PyCharm.

Slack

We'll be using Slack instead of the TRACS forums for online discussion. Slack is a group chat tool that's seeing a lot of adoption in various companies, and is a great example of modern web application design (with an unfortunate caveat or two).

Watch your e-mail for a Slack invitation, and follow the instructions to create an account.

Use of Slack is not mandatory. I do welcome e-mails about course materials, as well as visits to my office hours. However, I hope that it will be very useful to allow you to help each other, to all see the answers to questions, and to communicate among your project teams.

Moving on…

Once you have your accounts created, continue with the appropriate instructions for your OS:

Working in the Labs

The Linux lab machines should already have Git, Python, and PyCharm. They will not have Firefox Developer Edition installed, and SourceTree is not available for Linux.

You will have to be careful about the size of your home directory, since your quotas are small. Firefox and PyCharm can build large caches that eat up a lot of your home directory.

Python 3.4 is available at /usr/bin/python3.4. On a Red Hat machine (including Zeus), you can create a new virtual environment from the command line with:

pyvenv-3.4 ~/cs3320-env

The Ubuntu machines do not have the pyvenv-3.4 command, so you will need to use the older virtualenv:

virtualenv -p /usr/bin/python3.4 ~/cs3320-env

Windows Setup

A lot of the software you need has convenient Windows installers. There are a few operations we will perform from the command prompt (or PowerShell, which is nicer to work with on modern versions of Windows, particularly Windows 10).

Installing Git

Download the Windows installer from the Git website and run it. The default options are all fine; in particular, it will ask you about how to register Git on your PATH, and the default selection will work well. It is what I use on my own Windows machines.

Installing Python

Download the Python 3.4.4 installer from Python for Windows, either the x86 or x86-64 MSI installer. Using Python 3.4 will make it easier to avoid accidentally using features that are new to Python 3.5, which is not available on the servers we will be using.

Run the installer and accept most of the defaults. Towards the end of the installer, check the box to add Python to your PATH.

Note

If you have already installed another version of Python, it is best to uninstall it first. Having multiple versions of Python is complicated, especially if they both want to be on your PATH. If you regularly need to use multiple versions of Python, I recommend using Miniconda to install them, but it does not work well with virtual environments.

Installing PyCharm

Download PyCharm Professional Edition from the [PyCharm web site][]. You need the professional edition — the community edition does not contain support for developing web applications.

Run the installer to install PyCharm.

Once PyCharm is installed, launch it. It will prompt you to activate; log in with the JetBrains account you created earlier.

When you start trying to use Git, you may need to tell PyCharm where your Git installation is located. If it complains that it cannot find Git, do the following:

  1. Go to FileSettings
  2. Select Version Control and then Git
  3. Browse for a Git executable; it is usually under C:\Program Files\Git, or C:\Program Files(x86)\Git. There will be a bin directory, and git.exe or git.cmd inside that.

Creating a Virtual Environment

Open a command prompt (either Command Prompt or PowerShell will work). I recommend PowerShell.

If you are going to use PowerShell, you first need to change the execution policy. The default policy keeps scripts from running, which makes it difficult to use Python. Run the following to enable local scripts and remote scripts that have valid signatures:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Once you have done that, you can set up a virtual environment:

cd $env:USERPROFILE
python C:\Python34\Tools\Scripts\pyvenv.py cs3320-env
cs3320-env\Scripts\activate.ps1
pip install Flask Flask-Script

If you are using Command Prompt, you can use this:

cd %USERPROFILE%
python C:\Python34\Tools\Scripts\pyvenv.py cs3320-env
cs3320-env\Scripts\activate.bat
pip install Flask Flask-Script

Either of these commands will create a new Python virtual environment in C:\Users\username\cs3320-env. A virtual environment allows you to install packages and keep them isolated from the rest of your system.

Install Firefox Developer Edition (optional)

Download the installer from the FireFox web site and run it.

Install SourceTree (optional)

Download the installer from the SourceTree web site and run it.

When you start SourceTree, it will ask you to register. This is free, but requires you to create an Atlassian account.

OS X Setup

Setup on OS X involves some more command-line work. There are things that will make it easier, though.

Prerequisite: Installing Homebrew

Homebrew is a tool for OS X that makes it easier to install and manage additional software, particularly from a UNIX heritage. We're going to use it to install several of the utilities that we need.

Note

If you already use another tool such as MacPorts, that is fine; it includes all the software as well. However, I won't be able to provide much assistance on debugging it.

To install Homebrew, follow the instructions on its website.

Installing Git

OS X includes an old version of Git along with the XCode Command Line Tools. If you want to use that version, that's fine. Otherwise, we can install a newer version with Homebrew by running the following in a terminal:

brew install git

Installing Python

OS X includes Python 2 in the base operating system. We'll install Python 3.5 from Homebrew. Run the following in a terminal:

brew install python3

Installing PyCharm

Download PyCharm Professional Edition from the [PyCharm web site][]. You need the professional edition — the community edition does not contain support for developing web applications.

Open the disk image and copy the PyCharm app to your Applications folder.

Once PyCharm is installed, launch it. It will prompt you to activate; log in with the JetBrains account you created earlier.

Creating a Virtual Environment

Open a terminal, and run the following to create a Python virtual environment and install the Python libraries we need:

pyvenv-3.5 ~/cs3320-env
. ~/cs3320-env/bin/activate
pip install Flask Flask-Script

Install Firefox Developer Edition (optional)

Download the package from the FireFox web site and copy the application to your Applications folder

Install SourceTree (optional)

Download the package from the SourceTree web site and copy the application to your Applications folder.

When you start SourceTree, it will ask you to register. This is free, but requires you to create an Atlassian account.

Linux Setup

Most of the software that you need can be found in your Linux distribution's package repositories (the ones you access with apt-get or yum).

Installing Git

On most systems, the Git package is called git:

sudo apt-get install git # Debian / Ubuntu
sudo yum install git # Red Hat / Fedora / SuSE

Installing Python

On Debian and Ubuntu, you can run:

sudo apt-get install python3.4 python3.4-dev python3.4-venv python3-pip

On Red Hat and Fedora, run:

sudo yum install python34-devel /usr/bin/pyvenv-3.4

Installing PyCharm

Download PyCharm Professional Edition from the [PyCharm web site][]. You need the professional edition — the community edition does not contain support for developing web applications.

The download will be a gzipped tarball. Unpack it:

tar xvzf pycharm-professional-5.0.3.tar.gz

Then look inside the directory and follow the instructions.

Note

I don't have a Linux desktop to test detailed instructions. Additional instructions are welcome.

Once PyCharm is installed, launch it. It will prompt you to activate; log in with the JetBrains account you created earlier.

Creating a Virtual Environment

Open a terminal, and run the following to create a Python virtual environment and install the Python libraries we need:

pyvenv-3.4 ~/cs3320-env
. ~/cs3320-env/bin/activate
pip install Flask Flask-Script

Install Firefox Developer Edition (optional)

Download the package from the FireFox web site and download the installer. Unpack and/or run it.

Note

I don't have a Linux desktop to test detailed instructions. Additional instructions are welcome.

SourceTree

SourceTree is not available for Linux.

All done!

Once you have completed the instructions, you should be ready to work on the assignments and experiment with what you are learning.

If you find errors in these instructions, please file an issue on GitHub or send me an e-mail.