Skip to content

Running this code on your machine

DomKynkor edited this page Mar 17, 2017 · 11 revisions

How exactly does the ebook work?

This ebook might seem a bit strange. This Github repository contains a bunch of reStructuredText (.rst) files, a bunch of images, some Python files, and some text files---but no HTML files. So how does this become the website that students visit at http://interactivepython.org/runestone/static/StudentCSP/index.html?

What happens is that the ebook is "built" from the files in this repo into a series of HTML webpages. The runestone command line tool does this building for us, so we never have to write any HTML.

After being built, the ebook is "served" at a particular location. The people behind Runestone Interactive have served the ebook on one of their servers which is accessible via the web. When you are testing your changes to the ebook, you will want to serve your ebook locally, which means that you'll serve the website on your own computer. Don't worry, no one else can see it :)

Requirements

In order to do the building and serving described above, you'll need a tool called runestone. runestone is built in Python, and so to install it, we recommend using pip, the Python Package Installer.

Below are minimalist instructions for installing runestone that assume you are familiar with the command line and already have Python. There is another wiki page with Detailed instructions for installing runestone, which you should check out if you're unfamiliar with the command line or are unsure if you have Python.

###Step 1: Make sure you have pip You might have pip and not even know it. Run $ pip --version to find out

If something like this happens, you have pip!

MyComputer:~ myname$ pip --version
pip 8.1.1 from /Users/myname/anaconda/lib/python2.7/site-packages (python 2.7)

If something like this happens, you don't have pip.

MyComputer:~ myname$ pip --version
-bash: pip: command not found

If you don't have pip, follow these instructions to install it: https://pip.pypa.io/en/stable/installing/

###Step 2: Install runestone

On the command line, run pip install runestone

If the installation process pauses and asks a question, press enter to accept the installation.

Building and serving the ebook

Before you build and serve the ebook on your machine, you'll need a copy of the ebook. Check out Getting your own fork of the ebook if you're not sure about the best way to do that.

Once you have the ebook files on your computer, you'll need to navigate into that folder in the command line. You want to be inside the root folder of the ebook, where the _sources folder and pavement.py file are.

Then, run

 MyComputer:StudentCSP myname$ runestone build

When you see

 Done, StudentCSP build successful

Great! The ebook was successfully built. You'll notice that a build folder is now present. This folder contains the generated HTML files.

Next we need to serve the ebook. Run

 MyComputer:StudentCSP myname$ runestone serve

You will see

serving at port 8000

and your prompt will not return. That's okay.

Type in localhost:8000 in your web browser, and you should see the ebook!

When you want to build again, type control + C into the terminal window where you ran the serve command. That should stop the serving and return your prompt.

Runestone Diagram

Clone this wiki locally