SymPy code generation tutorial at SciPy 2017
Switch branches/tags
Nothing to show
Clone or download
Latest commit 4bd0cdb Jan 30, 2018
Failed to load latest commit information.
.jupyter Script for hosting jupyter notebook using docker Jun 22, 2017
bin Fix binder link Jan 30, 2018
conda-recipe Made the conda check work in environments. Fixes #21. Jul 7, 2017
environment Script for hosting jupyter notebook using docker Jun 22, 2017
intro-slides Add the link to the intro slides Jul 11, 2017
notebooks Merge branch 'master' of Jul 11, 2017
scipy2017codegen Use 'import sympy as sym' everywhere Jul 9, 2017
.drone.sec Update drone secret Jun 27, 2017
.drone.yml Juggle around environment.yml files again (fix: don't version channel) Jun 27, 2017
.gitignore Replace %exercise with %load prior to rendering notebooks Jul 6, 2017
.travis.yml Need a different git clean command Jul 10, 2017
Dockerfile Set CONDA_PREFIX manually in dockerimage for binder Jun 27, 2017
LICENSE Added BSD license. Jun 24, 2017 Add cfib example source files to Jul 6, 2017
README.rst Fix indentation Jul 10, 2017
appveyor.yml forward slash for appveyor Jul 7, 2017
circle.yml Only build circle on master Jul 10, 2017
environment-gcc.yml Use sundials 2.7.0 Jan 9, 2018
environment.yml Use sundials 2.7.0 Jan 9, 2018
github_deploy_key.enc First pass at getting doctr deploy working Jul 7, 2017
index.ipynb Add link to YouTube video to the index.ipynb Jul 12, 2017
setup.cfg More CI fixes Jun 13, 2017 More CI fixes Jun 22, 2017 Have to use shell=True in check_output for it to use PATH on Windows Jul 10, 2017 Added tutorial from wiki Jun 6, 2017


SciPy 2017 Codegen Tutorial


This repository contains all of the source code and Jupyter notebooks for the SciPy 2017 tutorial "Automatic Code Generation with SymPy".

The original proposal for this tutorial can be found on the SymPy Wiki.

The statically rendered Jupyter notebooks in this repository can be viewed at or on NBViewer.

Software Installation

We leverage the Conda package manager for installation of the necessary software on the three most popular platforms. Please install either Anaconda or Miniconda using the instructions provided at the download links.

If you are using Windows, please also install the Visual C++ Build Tools for proper Cython compilation with Python 3.5+. Install this before you arrive at the tutorial, as it takes some time.

You will need to download and unzip or clone this repository with Git so that the files are available on your computer. For example:

> wget
> unzip


> git clone

At the command line, change into the repository directory:

> cd /path/to/scipy-2017-codegen-tutorial

Creating a conda environment from environment.yml

Once you have conda installed, you can choose from one of our environment files that specifies our conda environment (named codegen17):

  • environment.yml (relies on your system compiler, e.g. gcc/clang/msvc on linux/osx/win)
  • environment-gcc.yml (installs conda's version of gcc)

we strongly encourage user to use environment.yml. At the command line, you can create this environment by executing e.g.:

> conda env create -f environment.yml

Run this command before you arrive at the tutorial, as it takes some time.

When installation is complete you may activate the environment by typing:

> activate codegen17

on Windows or using Bash on Linux/Mac):

$ source activate codegen17

To check to see if everything is installed correctly type:

(codegen17)> python

If there are no errors or warnings you have installed the software correctly.

To exit the environment you type:

(codegen17)> deactivate

If you for some reason want to remove the environment you can do so after deactivating by typing:

> conda env remove --name codegen17

on windows, and:

$ source deactivate

on Linux/Mac (using bash).

At this point you have everything installed to run the code in the tutorial.

Running the notebooks

After activating the codegen17 environment start Jupyter in the notebooks directory:

(codegen17)> jupyter notebook index.ipynb

A web interface should open in your web browser (default address http://localhost:8888). Note that Ctrl-C will stop the notebook server.

Optional Installation/Run Methods

Host a jupyter server using docker

If docker is installed it is possible to simply launch a jupyter notebook running in the correct environment by writing:

$ bin/

Note that it will download roughly ~1 GiB first time you run the command. Also note that you do not need to have conda installed on your machine to do this (conda is installed in the dockerimage).

Run notebooks using binder

Using only a web-browser (and an internet connection) it is possible to explore the notebooks here: (by the courtesy of the people behind mybinder)


Developing the notebooks

Note that you should remove the last line of environment.yml (i.e. scipy2017codegen) if you intend to make changes to the scipy2017codegen package (do not commit that change however). Otherwise conda will pull the package from:

It is recommended that you run python develop after having activated the codegen17 environment lacking our above mentioned package.

CI status

Below are the build status of the CI services set up to test the tutorial notebooks.

Travis CI (OS X)

Travis status

AppVeyor (Windows)

AppVeyor status

CircleCI (Linux - tests environment.yml)

Circle CI status

Drone (Dockerized Ubuntu 16.04 - tests environment-nogcc.yml)

Drone status