Before you continue, make sure that you are familiar with the subjects in the Install XBlock Prerequisites section.
When you have installed all prerequisites, you are ready to set up the XBlock SDK in a virtual environment. To do this, complete the following steps.
It is recommended that you create a directory in which to store all your XBlock work, including a virtual environment, the XBlock SDK, and the XBlocks you develop.
At the command prompt, run the following command to create the directory.
$ mkdir xblock_development
Change directories to the xblock_development
directory.
$ cd xblock_development
The rest of your work will be from this directory.
You must have a virtual environment tool installed on your computer. For more information, see Install XBlock Prerequisites.
Then create the virtual environment in your xblock_development
directory.
At the command prompt in xblock_development
, run the following
command to create the virtual environment.
$ virtualenv venv
Run the following command to activate the virtual environment.
$ source venv/bin/activate
When the virtual environment is activated, the command prompt shows the name of the virtual directory in parentheses.
(venv) $
The XBlock SDK is a Python application you use to help you build new XBlocks. The XBlock SDK contains three main components:
After you create and activate the virtual environment, you clone the XBlock SDK and install its requirements. To do this, complete the following steps at a command prompt.
In the xblock_development
directory, run the following command to clone
the XBlock SDK repository from GitHub.
(venv) $ git clone https://github.com/edx/xblock-sdk.git
Run the following command to change to the xblock-sdk
directory.
(venv) $ cd xblock-sdk
Run the following command to install the XBlock SDK requirements.
(venv) $ pip install -r requirements/base.txt
Run the following command to return to the xblock_development
directory,
where you will perform the rest of your work.
(venv) $ cd ..
When the requirements are installed, you are in the xblock_development
directory, which contains the venv
and xblock-sdk
subdirectories. You can now create your first XBlock.