From 1beb0ea5ffff8893970cc157f23a4122e7777c2c Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Wed, 28 Aug 2024 16:30:27 +0200 Subject: [PATCH] feat: update our fork with upstream version 3.13.4 * Fix: Restore __init__.py to fork version * Fix: Broken imports * feat: add a ci file to run pytests * fix: add needed pysodium dependency --------- Co-authored-by: Laurent Peuch --- .github/workflows/pytest.yml | 33 ++++++++++++++++++++++++++++++++ setup.cfg | 1 + src/aleph_pytezos/__init__.py | 34 +++++---------------------------- src/aleph_pytezos/crypto/key.py | 12 ++++-------- 4 files changed, 43 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/pytest.yml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..0b1b8ed --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,33 @@ +name: Test/Coverage with Python + +on: + push: + branches: + - main + pull_request: + branches: + - "*" + +jobs: + tests: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.12 + id: setup-python + uses: actions/setup-python@v2 + with: + python-version: 3.12 + + - name: Install needed debian packages + run: sudo apt install libsodium-dev libgmp-dev + + - name: Install project + run: pip install -e . + + - name: Install pytest and pytest-cov + run: pip install pytest pytest-cov + + - name: Run tests + run: pytest diff --git a/setup.cfg b/setup.cfg index 0958f75..9333bb7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,6 +56,7 @@ install_requires = coincurve >= 20.0.0 typing_extensions fastecdsa + pysodium [options.packages.find] where = src diff --git a/src/aleph_pytezos/__init__.py b/src/aleph_pytezos/__init__.py index 28a4741..1269106 100644 --- a/src/aleph_pytezos/__init__.py +++ b/src/aleph_pytezos/__init__.py @@ -1,31 +1,7 @@ -""" -Welcome to PyTezos! +from importlib.metadata import version -To start playing with the Tezos blockchain you need to get a PyTezosClient instance. -Just type: +# Change here if project is renamed and does not equal the package name +dist_name = "aleph-pytezos" +__version__ = version(dist_name) ->>> from pytezos import pytezos ->>> pytezos - -And follow the interactive documentation. -""" - -import importlib.metadata - -from pytezos.client import PyTezosClient -from pytezos.contract.interface import Contract -from pytezos.contract.interface import ContractInterface -from pytezos.crypto.key import Key -from pytezos.logging import logger -from pytezos.michelson.forge import forge_micheline -from pytezos.michelson.forge import unforge_micheline -from pytezos.michelson.format import micheline_to_michelson -from pytezos.michelson.micheline import MichelsonRuntimeError -from pytezos.michelson.parse import michelson_to_micheline -from pytezos.michelson.types.base import MichelsonType -from pytezos.michelson.types.base import Undefined -from pytezos.michelson.types.core import Unit - -__version__ = importlib.metadata.version('pytezos') - -pytezos = PyTezosClient() +__all__ = ["__version__"] diff --git a/src/aleph_pytezos/crypto/key.py b/src/aleph_pytezos/crypto/key.py index d7baac2..e3c3517 100644 --- a/src/aleph_pytezos/crypto/key.py +++ b/src/aleph_pytezos/crypto/key.py @@ -13,11 +13,7 @@ from mnemonic import Mnemonic -from pytezos.crypto.encoding import base58_decode -from pytezos.crypto.encoding import base58_encode -from pytezos.crypto.encoding import scrub_input -from pytezos.jupyter import InlineDocstring -from pytezos.jupyter import get_class_docstring +from aleph_pytezos.crypto.encoding import base58_decode, scrub_input, base58_encode VALID_MNEMONIC_LENGTHS = [12, 15, 18, 21, 24] DEFAULT_LANGUAGE = 'english' @@ -100,7 +96,7 @@ def validate_mnemonic(mnemonic: str, language: str = DEFAULT_LANGUAGE) -> None: raise ValueError('Mnemonic checksum verification failed') -class Key(metaclass=InlineDocstring): +class Key: """Represents a public or secret key for Tezos. Ed25519, Secp256k1 and P256 are supported. """ @@ -122,8 +118,8 @@ def __repr__(self) -> str: super().__repr__(), '\nPublic key hash', self.public_key_hash(), - '\nHelpers', - get_class_docstring(self.__class__), + '\nClass', + self.__class__, ] return '\n'.join(res)