Giter VIP home page Giter VIP logo

bdk-python's Introduction

bdk-python

The Python language bindings for the bitcoindevkit.

See the package on PyPI.

Currently supported architectures:

  • macOS arm64
  • macOS x86_64
  • linux x86_64

Install from PyPI

Install the latest release using

pip install bdkpython

Run the tests

python -m tox

Build the package

python -m build

Install locally

pip install ./dist/bdkpython-0.0.1-py3-none-any.whl

Known issues

Note that until the fix is merged upstream in uniffi-rs, the loadIndirect() function in the bdk.py module must be replaced with the following:

def loadIndirect():
    if sys.platform == "linux":
        # libname = "lib{}.so"
        libname = os.path.join(os.path.dirname(__file__), "lib{}.so")
    elif sys.platform == "darwin":
        # libname = "lib{}.dylib"
        libname = os.path.join(os.path.dirname(__file__), "lib{}.dylib")
    elif sys.platform.startswith("win"):
        # As of python3.8, ctypes does not seem to search $PATH when loading DLLs.
        # We could use `os.add_dll_directory` to configure the search path, but
        # it doesn't feel right to mess with application-wide settings. Let's
        # assume that the `.dll` is next to the `.py` file and load by full path.
        libname = os.path.join(
            os.path.dirname(__file__),
            "{}.dll",
        )
    return getattr(ctypes.cdll, libname.format("bdkffi"))

Support both macOS architectures

In order to support both macOS architectures, we must modify the loadIndirect() method a little further:

import platform
def loadIndirect():
    if sys.platform == "linux":
        # libname = "lib{}.so"
        # libname = os.path.join(os.path.dirname(__file__), "lib{}.so")
        libname = os.path.join(os.path.dirname(__file__), "linux-x86_64/lib{}.so")
    elif sys.platform == "darwin":
        # libname = "lib{}.dylib"
        # libname = os.path.join(os.path.dirname(__file__), "lib{}.dylib")
        if platform.machine() == "arm64":
            libname = os.path.join(os.path.dirname(__file__), "darwin-arm64/lib{}.dylib")
        elif platform.machine() == "x86_64":
            libname = os.path.join(os.path.dirname(__file__), "darwin-x86_64/lib{}.dylib")
    elif sys.platform.startswith("win"):
        # As of python3.8, ctypes does not seem to search $PATH when loading DLLs.
        # We could use `os.add_dll_directory` to configure the search path, but
        # it doesn't feel right to mess with application-wide settings. Let's
        # assume that the `.dll` is next to the `.py` file and load by full path.
        libname = os.path.join(
            os.path.dirname(__file__),
            "{}.dll",
        )
    return getattr(ctypes.cdll, libname.format("bdkffi"))

bdk-python's People

Contributors

thunderbiscuit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.