Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python - autonomi client #2372

Merged
merged 2 commits into from
Nov 7, 2024
Merged

Python - autonomi client #2372

merged 2 commits into from
Nov 7, 2024

Conversation

dirvine
Copy link
Member

@dirvine dirvine commented Nov 2, 2024

Python Bindings for Autonomi Client

What does this PR do?

  • Adds Python bindings for the Autonomi client library using PyO3
  • Sets up automated wheel building for multiple Python versions (3.8-3.12)
  • Configures cross-platform builds (Linux, macOS, Windows)
  • Publishes package to PyPI as autonomi-client

Changes include:

  1. Added PyO3 configuration and dependencies
  2. Created Python module structure:
    • autonomi_client package
    • Python bindings initialization
    • Version synchronization with Rust crate
  3. Added GitHub Actions workflow for:
    • Building wheels for all supported platforms
    • Building source distribution
    • Publishing to PyPI
  4. Added necessary build configuration:
    • pyproject.toml for Python package metadata
    • Maturin build configuration
    • Cross-platform compatibility settings

Testing

  • Automated builds for Python 3.8-3.12
  • Platform coverage:
    • Linux (x86_64, manylinux2014)
    • macOS (x86_64, aarch64)
    • Windows (x64)

Documentation

The Python package can be installed via pip:


def main():
# Connect to network
client = Client(["/ip4/127.0.0.1/tcp/12000"])

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
autonomi/src/python.rs Fixed Show fixed Hide fixed
#[new]
fn new(private_key: String) -> PyResult<Self> {
let wallet = RustWallet::new_from_private_key(
EvmNetwork::ArbitrumOne, // TODO: Make this configurable

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment

def main():
# Configuration
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"

Check failure

Code scanning / devskim

A token or key was found in source code. If this represents a secret, it should be moved somewhere else. Error

Do not store tokens or keys in source code.
def main():
# Configuration
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
peers = ["/ip4/127.0.0.1/tcp/12000"]

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production

def main():
# Initialize wallet and client
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"

Check failure

Code scanning / devskim

A token or key was found in source code. If this represents a secret, it should be moved somewhere else. Error

Do not store tokens or keys in source code.
def main():
# Initialize wallet and client
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
peers = ["/ip4/127.0.0.1/tcp/12000"]

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
def main():
# Initialize a wallet with a private key
# This should be a valid Ethereum private key (64 hex chars without '0x' prefix)
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"

Check failure

Code scanning / devskim

A token or key was found in source code. If this represents a secret, it should be moved somewhere else. Error

Do not store tokens or keys in source code.
def main():
# Initialize
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
peers = ["/ip4/127.0.0.1/tcp/12000"]

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production

def main():
# Initialize
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"

Check failure

Code scanning / devskim

A token or key was found in source code. If this represents a secret, it should be moved somewhere else. Error

Do not store tokens or keys in source code.
def main():
# Initialize
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
peers = ["/ip4/127.0.0.1/tcp/12000"]

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production

def main():
# Initialize
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"

Check failure

Code scanning / devskim

A token or key was found in source code. If this represents a secret, it should be moved somewhere else. Error

Do not store tokens or keys in source code.
def main():
# Initialize
private_key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
peers = ["/ip4/127.0.0.1/tcp/12000"]

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
@dirvine dirvine force-pushed the python branch 2 times, most recently from fff46fd to 5e3ee09 Compare November 3, 2024 22:12
@@ -0,0 +1,190 @@
name: Build and Publish Python Package

on:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the whole trigger for now and just commit the workflow without it?

So for now, it won't fire, but we can add the trigger back in when we are ready.

@dirvine dirvine force-pushed the python branch 4 times, most recently from 511585b to 387ce0a Compare November 7, 2024 20:57
This commit introduces Python bindings for the Autonomi crate using PyO3,
making the Autonomi network client accessible from Python applications.

Key changes:
- Add autonomi-py crate with PyO3 bindings
- Configure workspace to include Python package
- Set up maturin build system for Python package
- Add GitHub Actions workflow for building and publishing Python wheels
- Configure cross-platform builds for Linux, macOS, and Windows
- Add Python 3.8-3.12 support

The Python package provides bindings for core Autonomi functionality including:
- Network client connection
- Data upload/download
- Wallet management
- Payment handling

Build artifacts will be published to PyPI when a new version is tagged.
@jacderida jacderida merged commit 72dd3e2 into maidsafe:main Nov 7, 2024
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants