Skip to main content

Integration SDK for Mesh API Services

Project description

Python SDKs for Mesh APIs

CI Status

This directory is the Python Monorepo for all official Mesh API client SDKs.

Quick Start for API Consumers

This guide is for developers who want to use these SDKs in their own applications.

1. Installation

Install the desired SDK integration library from PyPI using pip:

pip install meshtrade

2. Example Usage

Here is a basic example of how to use SDK clients:

import asyncio
from meshtrade.account.v1 import AccountService
from meshtrade.iam.v1 import as IAMService

# NOTE: ensure that MESH_API_KEY="your-secret-api-key" is set

async def main():
    # Instantiate the client for the Account v1 service
    account_client = AccountService()

    # Call an RPC method
    try:
        response = await account_client.get(number="1000111")
        print("Successfully retrieved account:", response.account)
    except Exception as e:
        print(f"An error occurred: {e}")
    
    # You can similarly use other clients
    iam_client = IAMService()
    # ... use iam_client ...

if __name__ == "__main__":
    asyncio.run(main())

For more detailed information on each SDK, please see their individual READMEs:

Repository Structure

This directory is a workspace within a larger polyglot monorepo. It manages versioned Python packages for each integration SDK.

└── python
    ├── README.md               <-- You are HERE
    ├── pyproject.toml          <-- SDK workspace configuration
    ├── requirements-dev.txt    <-- SDK Workspace development requirements
    ├── tox.ini                 <-- Task automation configuration
    ├── src
    │   └── meshtrade
    │       ├── __init__.py
    │       └── account         <-- Defines the mesh account api service
    │           └── vX          <-- Defines the mesh account vX api SDK
    │               ├── __init__.py
    │               ├── account_pb2.py
    │               └── README.md
    └── tests
        ├── integration
        └── unit

Developer Guide

This guide is for developers contributing to these SDKs. It explains how to set up the local development environment for this Python monorepo.

1. Prerequisites:

  • Python 3.8+
  • The venv module (usually included with Python)

2. Environment Setup

All commands should be run from within this python/ directory.

Create and activate a single shared virtual environment for the workspace:

python3 -m venv .venv
source .venv/bin/activate

Your terminal prompt should now be prefixed with (.venv), indicating the environment is active.

Tip: If you are in an IDE that supports python you can point your IDE to the interpreter in this environment relative to the source of the repository: ./python/.venv/bin/python. e.g. with VS code:

'cmd + shift + p' > 'Python: Select Interpreter' > 'Enter interpreter path...' > './python/.venv/bin/python'

3. Install Dependencies

This project uses pip-tools to manage dependencies for a reproducible development environment. The top-level pyproject.toml is the source of truth for our direct dependencies, and requirements-dev.txt is the "lock file" that guarantees identical setups for everyone.

A) For a new setup (e.g. after a git pull):

Install the locked dependencies from requirements-dev.txt:

pip install -r requirements-dev.txt

This synchronises the local virtual environment to match the exact versions in the lock file.

Once this is complete you are set up to begin programming in the sdk source code in: ./python/src/mesh.

Next to make the SDK discoverable locally for tests do:

pip install -e .

B) After a manual change to pyproject.toml (e.g. to install a new workspace level dependency or bump its version):

If changes are made in the pyproject.toml then the lockfile must be regenerated:

# Step 1: Re-compile the dependencies to update the lock file
pip-compile --extra=dev --output-file=requirements-dev.txt pyproject.toml

# Step 2: Synchronise the local virtual environment again with the newly updated lock file
pip install -r requirements-dev.txt

4. Run Common Development Tasks

Tox is used as the as the main command runner for all common tasks like linting, testing, and building.

Tasks can be run from the command line (within the active virtual environment) as follows:

  • The linter:
tox -e lint
  • The unit tests:
tox -e unit-tests
  • The integration tests:
MESH_API_KEY="your-secret-api-key" tox -e integration-tests
  • All checks (linting and unit tests):
tox

5. Building and Publishing Packages

  • Build all packages: The build task in tox will create the distributable wheel (.whl) and sdist (.tar.gz) files for all packages and place them in their respective dist/ folders.
tox -e build
  • Publish to PyPi: The twine tool is used to securely upload the built packages to PyPI. This is done as part of the official release process.
twine upload lib/*/v*/dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meshtrade-0.0.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meshtrade-0.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file meshtrade-0.0.1.tar.gz.

File metadata

  • Download URL: meshtrade-0.0.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for meshtrade-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c8ec9602e36426b6f01b3a9508f2506c93c3e054ba619923e4964d2ae4fc2c3f
MD5 49f3c6f9dfa36f6da06234d407aaee84
BLAKE2b-256 ef8c0e9bf0d7c0c2eb0084aa9971507fa2da6fbc3fb1e47f6699331313fd3000

See more details on using hashes here.

File details

Details for the file meshtrade-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: meshtrade-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for meshtrade-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19c7c8eb4aba9a029647e833e43d4978eea55a24ec7c070b1f25e606f703d205
MD5 d1d0b917f91645c312742d770fd7f4cc
BLAKE2b-256 b27b1454e1698b4615e132dcc919ae951be5cac2dd57702e08bc4210f5123542

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page