From 57799d6977c3c2d221f380f617286476e34c0687 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 10 Nov 2023 16:00:48 +0000 Subject: [PATCH] setup.cfg: add urls, classifiers; add pylint workflow --- .github/workflows/pylint.yaml | 36 +++++++++++++++++++++++++++++++++ mmgen/data/version | 2 +- mmgen/keygen.py | 4 ++-- mmgen/proto/secp256k1/keygen.py | 13 ++++++++---- setup.cfg | 8 ++++++++ 5 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/pylint.yaml diff --git a/.github/workflows/pylint.yaml b/.github/workflows/pylint.yaml new file mode 100644 index 00000000..202200b1 --- /dev/null +++ b/.github/workflows/pylint.yaml @@ -0,0 +1,36 @@ +name: Pylint + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.9","3.10","3.11"] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Ubuntu dependencies + run: sudo apt-get update && sudo apt-get install curl + + - name: Install Python dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install gmpy2 cryptography pynacl ecdsa aiohttp requests pexpect scrypt semantic-version + python3 -m pip install pycryptodomex pysocks + python3 -m pip install --no-deps py_ecc==1.6.0 mypy_extensions==0.4.1 + python3 -m pip install pylint + + - name: Check the code with pylint static code analyzer + run: | + pylint --errors-only mmgen + pylint --errors-only test + pylint --errors-only --disable=relative-beyond-top-level test/cmdtest_py_d diff --git a/mmgen/data/version b/mmgen/data/version index 8fecd3de..6e48c174 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -14.0.dev13 +14.0.dev14 diff --git a/mmgen/keygen.py b/mmgen/keygen.py index 1ab9d242..48d8337c 100755 --- a/mmgen/keygen.py +++ b/mmgen/keygen.py @@ -44,7 +44,7 @@ class keygen_base: return None @classmethod - def test_avail(cls,cfg,silent=False): + def get_clsname(cls,cfg,silent=False): return cls.__name__ backend_data = { @@ -119,6 +119,6 @@ def KeyGenerator(cfg,proto,pubkey_type,backend=None,silent=False): backend_clsname = getattr( pubkey_type_cls, backend_id.replace('-','_') - ).test_avail(cfg,silent=silent) + ).get_clsname(cfg,silent=silent) return getattr(pubkey_type_cls,backend_clsname)(cfg) diff --git a/mmgen/proto/secp256k1/keygen.py b/mmgen/proto/secp256k1/keygen.py index 4e6f0cc0..de0ba867 100755 --- a/mmgen/proto/secp256k1/keygen.py +++ b/mmgen/proto/secp256k1/keygen.py @@ -20,8 +20,13 @@ class backend: class libsecp256k1(keygen_base): def __init__(self,cfg): - from .secp256k1 import priv2pub - self.priv2pub = priv2pub + # catch ImportError to satisfy pylint when testing repo with unbuilt secp256k1 extension mod: + try: + from .secp256k1 import priv2pub + self.priv2pub = priv2pub + except ImportError: + from ...util import die + die(3,'libsecp256k1.keygen.backend: you shouldn’t be seeing this') def to_pubkey(self,privkey): return PubKey( @@ -29,7 +34,7 @@ class backend: compressed = privkey.compressed ) @classmethod - def test_avail(cls,cfg,silent=False): + def get_clsname(cls,cfg,silent=False): try: from .secp256k1 import priv2pub if not priv2pub(bytes.fromhex('deadbeef'*8),1): @@ -37,7 +42,7 @@ class backend: die( 'ExtensionModuleError', 'Unable to execute priv2pub() from secp256k1 extension module' ) return cls.__name__ - except Exception as e: + except ImportError as e: if not silent: from ...util import ymsg ymsg(str(e)) diff --git a/setup.cfg b/setup.cfg index 5d85f2bf..66cb4c0a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,12 +19,20 @@ license = GNU GPL v3 platforms = Linux, Armbian, Raspbian, MS Windows keywords = file: mmgen/data/keywords project_urls = + Website = https://mmgen-wallet.cc Bug Tracker = https://github.com/mmgen/mmgen/issues + Documentation = https://github.com/mmgen/mmgen/wiki classifiers = Programming Language :: Python :: 3 + Programming Language :: C License :: OSI Approved :: GNU General Public License v3 (GPLv3) Operating System :: POSIX :: Linux Operating System :: Microsoft :: Windows + Environment :: Console + Topic :: Office/Business :: Financial + Topic :: Security :: Cryptography + Topic :: Software Development :: Libraries :: Python Modules + Development Status :: 5 - Production/Stable [options] python_requires = >=3.7