The preferred method of setting up the development environment is to use the devcontainers. All configuration files for VSCode and Gitpod are already placed in this repository. If you are new to the concept of devcontainers in combination with VSCode here is a good article about it.
Simply clone this repository and VSCode will most likely ask you to open it in the devcontainer, if you have the correct extension("ms-vscode-remote.remote-containers") installed.
If VSCode didn't ask to open it, open the command palette and use the Remote-Containers: Rebuild and Reopen in Container
command.
If you want to use Gitpod simply use this link
or if you want to work with your fork, prefix the entire URL of your branch with gitpod.io/#
so that it looks like https://gitpod.io/#https://github.com/hyperledger/indy-node/tree/main
.
Note: Be aware that the config files for Gitpod and VSCode are currently only used in the main
branch!
There are also scripts that can help in setting up an environment and project for developers. The scripts are in dev-setup folder. Note: Beware that these may be outdated and more cumbersome to set up.
Note: As of now, we provide scripts for Ubuntu only. It's not guaranteed that the code is working on Windows.
- One needs Python 3.5 to work with the code
- We recommend using Python virtual environment for development
- We use pytest for unit and integration testing
- There are some dependencies that must be installed before being able to run the code
This is a Quick Setup for development on a clean Ubuntu 16.04 machine. You can also have a look at the scripts mentioned below to follow them and perform setup manually.
- Get scripts from dev-setup-ubuntu
- Run
setup-dev-python.sh
to setup Python3.5, pip and virtualenv - Run
source ~/.bashrc
to apply virtual environment wrapper installation - Run
setup-dev-depend-ubuntu16.sh
to setup dependencies (libindy, ursa, libsodium) - Fork indy-plenum and indy-node
- Go to the destination folder for the project
- Run
init-dev-project.sh <github-name> <new-virtualenv-name>
to clone indy-plenum and indy-node projects and create a virtualenv to work in - Activate new virtualenv
workon <new-virtualenv-name>
- [Optionally] Install Pycharm
- [Optionally] Open and configure projects in Pycharm:
- Open both indy-plenum and indy-node in one window
- Go to
File -> Settings
- Configure Project Interpreter to use just created virtualenv
- Go to
Project: <name> -> Project Interpreter
- You’ll see indy-plenum and indy-node projects on the right side tab.
For each of them:
- Click on the project just beside “Project Interpreter” drop down, you’ll see one setting icon, click on it.
- Select “Add Local”
- Select existing virtualenv path as below: /bin/python3.5 For example: /home/user_name/.virtualenvs/new-virtualenv-name>/bin/python3.5
- Go to
- Configure Project Dependency
- Go to
Project: <name> -> Project Dependencies
- Mark each project to be dependent on another one
- Go to
- Configure pytest
- Go to
Configure Tools -> Python Integrated tools
- You’ll see indy-plenum and indy-node projects on the right side tab.
For each of them:
- Select Py.test from the ‘Default test runner’
- Go to
- Press
Apply
One needs Python 3.5 to work with the code. You can use dev-setup/ubuntu/setup_dev_python.sh
script for quick installation of Python 3.5, pip
and virtual environment on Ubuntu, or follow the detailed instructions below.
-
Run
sudo add-apt-repository ppa:deadsnakes/ppa
-
Run
sudo apt-get update
-
On Ubuntu 14, run
sudo apt-get install python3.5
(python3.5 is pre-installed on most Ubuntu 16 systems; if not, do it there as well.)
Run sudo yum install python3.5
-
Go to python.org and from the "Downloads" menu, download the Python 3.5.0 package (python-3.5.0-macosx10.6.pkg) or later.
-
Open the downloaded file to install it.
-
If you are a homebrew fan, you can install it using this brew command:
brew install python3
-
To install homebrew package manager, see: brew.sh
Download the latest build (pywin32-220.win-amd64-py3.5.exe is the latest build as of this writing) from here and run the downloaded executable.
Indy also depends on libsodium, an awesome crypto library. These need to be installed separately.
-
We need to install libsodium with the package manager. This typically requires a package repo that's not active by default. Inspect
/etc/apt/sources.list
file with your favorite editor (using sudo). On ubuntu 16, you are looking for a line that saysdeb http://us.archive.ubuntu.com/ubuntu xenial main universe
. On ubuntu 14, look for or add:deb http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main
anddeb-src http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main
. -
Run
sudo apt-get update
. On ubuntu 14, if you get a GPG error about public key not available, run this command and then, after, retry apt-get update:sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B9316A7BC7917B12
-
Install libsodium; the version depends on your distro version. On Ubuntu 14, run
sudo apt-get install libsodium13
; on Ubuntu 16, runsudo apt-get install libsodium18
Run sudo yum install libsodium-devel
Once you have homebrew installed, run brew install libsodium
to install libsodium.
-
Go to https://download.libsodium.org/libsodium/releases/ and download the latest libsodium package (libsodium-1.0.8-mingw.tar.gz is the latest version as of this writing).
-
When you extract the contents of the downloaded tar file, you will see 2 folders with the names libsodium-win32 and libsodium-win64.
-
As the name suggests, use the libsodium-win32 if you are using 32-bit machine or libsodium-win64 if you are using a 64-bit operating system.
-
Copy the libsodium-x.dll from libsodium-win32\bin or libsodium-win64\bin to C:\Windows\System or System32 and rename it to libsodium.dll.
Indy depends on RocksDB, an embeddable persistent key-value store for fast storage.
Currently Indy requires RocksDB version 5.8.8 or higher. There is a deb package of RocksDB-5.8.8 and related stuff that can be used on Ubuntu 16.04:
# Start of repository configuration steps
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CE7709D068DB5E88
sudo add-apt-repository "deb https://repo.sovrin.org/deb xenial master"
# End of repository configuration steps
sudo apt-get update
sudo apt-get install libbz2-dev \
zlib1g-dev \
liblz4-dev \
libsnappy-dev \
rocksdb=5.8.8
See RocksDB on how it can be installed on other platforms.
Indy needs Libindy as a test dependency. It also relies on ursa, a library that supplies cryptographic signatures.
There are deb packages of libindy and ursa that can be used on Ubuntu:
sudo add-apt-repository "deb https://repo.sovrin.org/sdk/deb xenial stable"
sudo apt-get update
sudo apt-get install -y libindy ursa
See Libindy on how libindy can be installed on other platforms. See Ursa build environment on how Ursa can be installed and built for other platforms.
We recommend creating a new Python virtual environment for trying out Indy. A virtual environment is a Python environment which is isolated from the system's default Python environment (you can change that) and any other virtual environment you create.
You can create a new virtual environment by:
virtualenv -p python3.5 <name of virtual environment>
And activate it by:
source <name of virtual environment>/bin/activate
Optionally, you can install virtual environment wrapper as follows:
pip3 install virtualenvwrapper
echo '' >> ~/.bashrc
echo '# Python virtual environment wrapper' >> ~/.bashrc
echo 'export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3' >> ~/.bashrc
echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc
echo 'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc
source ~/.bashrc
It allows to create a new virtual environment and activate it by using
mkvirtualenv -p python3.5 <env_name>
workon <env_name>
Activate the virtual environment.
Navigate to the root directory of the source (for each project) and install required packages by
pip install -e .[tests]
If you are working with both indy-plenum and indy-node, then please make sure that both projects are installed with -e option,
and not from pypi (have a look at the sequence at init-dev-project.sh
).
Go to the folder with tests (either indy-plenum
, indy-node/indy_node
, indy-node/indy_client
or indy-node/indy_common
)
and run tests
pytest .