Build and Import Affinidi TDK Python Packages

Build the Affinidi TDK Python package locally and import it into your application to integrate with the Affinidi Trust Network.

This guide will help you build and install locally and import the Python packages of Affinidi TDK into your application from the Github repository.

Before you begin
  1. Make sure you have Git installed on your machine. Follow this guide on how to install Git.

  2. Install Python, including pip on your machine if you haven’t installed yet using this guide.

Build Packages Module

To build the Python version of the Packages modules of the Affinidi TDK, we will be using the JSII module and run the following commands:

In this example, we will build and install the AuthProvider package.

  1. Go to your desired directory and clone the Affinidi TDK repository.

git clone git@github.com:affinidi/affinidi-tdk.git
  1. Go to the cloned repository and then go to the packages/auth-provider folder from your command line interface.

cd packages/auth-provider
  1. Install the Node modules with --prefix flag.

npm i --prefix .
  1. After successfully installing the dependencies, run the build command:

npm run build
  1. After successfully building the package, run the command to create the JSII package.

npm run package

After running the command, a Wheel (WHL) package is created in the dist folder.

  1. Install the generated Wheel (WHL) file on your machine:

pip install dist/python/<GENERATED_WHEEL_FILE>.whl

Replace the <GENERATED_WHEEL_FILE> with the generated wheel file name.

Lastly, import the package into your application:


import affinidi_tdk_auth_provider

You can follow the same steps to build the iota-core library except for iota-browser, which is a browser-only library.

Build Clients Module

To build and install the Affinidi TDK clients, we will use the setuptools and run the setup.py file provided on each client.

In this example, we will build and install the credential-issuance client.

  1. Go to your desired directory and clone the Affinidi TDK repository.

git clone git@github.com:affinidi/affinidi-tdk.git
  1. Go to the cloned repository and then go to the clients/python/credential_issuance_client folder from your command line interface.

cd clients/python/credential_issuance_client
  1. Install the setuptools package on your machine if you haven’t installed it yet.

pip install setuptools
  1. Run the setup.py file provided in the client’s folder.

python setup.py install --user
  1. Once the Python package is successfully built, you can now import the package.

import affinidi_tdk_credential_issuance_client

Stay tuned once we publish Affinidi TDK Python modules to the Python Package Index (PyPI) repository.