There are scripts that can help in setting up environment and project for developers. The scripts are in dev-setup folder.
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 (charm-crypto, libindy, libindy-crypto, 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 virtualenvironment 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-client requires anonymous credentials library which requires a cryptographic library.
The default configuration includes an example that uses Charm-Crypto framework.
You can install it as described in Anonymous Credentials repository
(in particular, running setup-charm.sh
).
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 Indy-Crypto.
There is a deb package of libindy-crypto that can be used on Ubuntu:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88
sudo add-apt-repository "deb https://repo.sovrin.org/deb xenial master"
sudo apt-get update
sudo apt-get install libindy-crypto
See Indy-Crypto on how it can be installed on other platforms.
Indy needs Libindy as a test dependency.
There is a deb package of libindy 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
See Libindy on how it can be installed on 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 .