Skip to content
tanaya-bigladder edited this page Jan 27, 2020 · 8 revisions

Setting Up Toolkit 205 for Visual Studio Code

This wiki provides a guide for setting up Toolkit 205 for testing and development inside of Visual Studio Code.

Directions for downloading the Toolkit 205 repository can be found in the Toolkit 205 Readme file inside the repository on Github.

Why Visual Studio Code?

Visual Studio Code is a free and cross platform Integrated Development Environment (IDE) provided by Microsoft which allows the integration of open source extensions to customize the environment. The current state of support for Python modules in Visual Studio Code is quite good, and combined with its accessibility at no cost on all operating systems makes it an ideal tool for building, testing, and debugging Toolkit 205.

Installing Visual Studio Code

Visual Studio Code can be downloaded for the appropriate operating system here. Simply click the large blue button to start the download for the installer, and follow the appropriate steps to get it installed with default settings.

Installing Python

The core components of Toolkit 205 are written in Python 3.x so a version of the Python 3 interpreter will be required to run the code and tests in the toolkit.

The latest version of Python 3 can be downloaded from the Python Organization here.

Alternatively, a popular way to add Python to a system is to use the Anaconda distributable. This can be downloaded for free here.

Configuring the Python Environment

No matter which Python 3 interpreter is on your system, or which version of multiple you would like to use, Visual Studio Code will need to be configured to use the desired interpreter. To do this open the Command Palette (Ctrl-Shift-P for Windows; Cmd-Shift-P on Mac) and start typing the command:

`Extensions: Install Extensions`

Select/install the Python Extension published by Microsoft. When this is finished installing, open the Command Palette again and type:

`Python: Select Interpreter`

This will allow you to choose between a list of known Python interpreters. Select the one you wish to use.

Getting Pipenv

Toolkit 205 takes advantage of Pipenv, and environment and package management tool for python. To use this tool, pipenv will need to be installed.

To install pipenv with Pip, the standard python package management tool, type the following into a command prompt which has access to Python:

`pip install pipenv`

To install pip with the Anaconda python distributable, open a "Conda Prompt" and type the following command:

`conda install pipenv`

Installing Pipenv Development Packages

With pipenv installed, the environment for Toolkit 205 can now be set up. Open Visual Studio Code, and open the the Toolkit 205 repository.

Inside of Visual Studio Code, open a new terminal (Ctrl+`), and type the following command:

`pipenv install --dev`

In order to activate the environment

`pipenv shell`

Install Toolkit205

With the environment now setup, it is time to add 'tk205' as a module available to Python. This is done by running the setup.py file in the repository. To do this, open the terminal in Visual Studio Code, navigate to the toolkit-205 repository directory, and run the following command:

`pip install .`

Configuring Pytest

The repository is now setup to run Python code for the project. However, Visual Studio Code is not yet aware of the testing framework or existing tests inside the repository. Toolkit 205 uses 'Pytest', a popular testing framework for Python projects, and should be available to the project inside of the pipenv environment. You can test if 'Pytest' is available by typing the following command into the Visual Studio Code terminal:

`pytest`

In order to inform Visual Studio Code of this testing framework, open the Command Palette and type the following:

`Python: Configure Tests`

Then select pytest when prompted to select a testing framework, and select test when asked to specify which folder contains this projects tests.

This will create a new pane on the far left panel inside Visual Studio Code which looks like a lab beaker. This is the test panel. Click and open this panel to bring up the test menu. Here, the user can choose to run individual tests by pressing the green play button, or to debug a test by pressing the button which looks like a six legged bug.

Last, we need to discover these tests. Open the Command Palette and type the following:

`Python: Discover Tests`

Follow the dialog and select the test folder as the folder which contains our tests.

You're all set! Toolkit 205 is now ready for testing or development on your system.

Clone this wiki locally