From b0f8a99310dba666d53c04fff7267dbc7b67de3f Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 21 Feb 2022 19:43:40 +0100 Subject: [PATCH] pyln: Migrate pyln-bolt7 to PEP517 (poetry) --- contrib/pyln-spec/bolt7/.gitignore | 1 + .../bolt7/pyln/spec/bolt7/__init__.py | 26 ++++++++- .../pyln-spec/bolt7/pyln/spec/bolt7/bolt.py | 6 ++- contrib/pyln-spec/bolt7/pyproject.toml | 20 +++++++ contrib/pyln-spec/bolt7/requirements.txt | 1 - contrib/pyln-spec/bolt7/setup.py | 53 ------------------- 6 files changed, 51 insertions(+), 56 deletions(-) create mode 100644 contrib/pyln-spec/bolt7/.gitignore mode change 120000 => 100644 contrib/pyln-spec/bolt7/pyln/spec/bolt7/__init__.py mode change 120000 => 100644 contrib/pyln-spec/bolt7/pyln/spec/bolt7/bolt.py create mode 100644 contrib/pyln-spec/bolt7/pyproject.toml delete mode 100644 contrib/pyln-spec/bolt7/requirements.txt delete mode 100644 contrib/pyln-spec/bolt7/setup.py diff --git a/contrib/pyln-spec/bolt7/.gitignore b/contrib/pyln-spec/bolt7/.gitignore new file mode 100644 index 000000000..c04bc49f7 --- /dev/null +++ b/contrib/pyln-spec/bolt7/.gitignore @@ -0,0 +1 @@ +poetry.lock diff --git a/contrib/pyln-spec/bolt7/pyln/spec/bolt7/__init__.py b/contrib/pyln-spec/bolt7/pyln/spec/bolt7/__init__.py deleted file mode 120000 index 52f300f8a..000000000 --- a/contrib/pyln-spec/bolt7/pyln/spec/bolt7/__init__.py +++ /dev/null @@ -1 +0,0 @@ -../../../../subinit.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt7/pyln/spec/bolt7/__init__.py b/contrib/pyln-spec/bolt7/pyln/spec/bolt7/__init__.py new file mode 100644 index 000000000..749979a1e --- /dev/null +++ b/contrib/pyln-spec/bolt7/pyln/spec/bolt7/__init__.py @@ -0,0 +1,25 @@ +# This is the same __init__.py for all bolt dirs. +from .csv import csv +from .text import text, desc +from .gen_csv_version import __csv_version__ +from .gen_version import __base_version__, __post_version__, __gitversion__ +from .bolt import namespace +import sys + +# eg. 1.0.1.137. +__version__ = '{}.{}.{}'.format(__base_version__, __csv_version__, __post_version__) + +__all__ = [ + 'csv', + 'text', + 'desc', + 'namespace', + '__version__', + '__gitversion__', +] + +mod = sys.modules[__name__] +for d in namespace.subtypes, namespace.tlvtypes, namespace.messagetypes: + for name in d: + setattr(mod, name, d[name]) + __all__.append(name) diff --git a/contrib/pyln-spec/bolt7/pyln/spec/bolt7/bolt.py b/contrib/pyln-spec/bolt7/pyln/spec/bolt7/bolt.py deleted file mode 120000 index c22b879fc..000000000 --- a/contrib/pyln-spec/bolt7/pyln/spec/bolt7/bolt.py +++ /dev/null @@ -1 +0,0 @@ -../../../../bolt.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt7/pyln/spec/bolt7/bolt.py b/contrib/pyln-spec/bolt7/pyln/spec/bolt7/bolt.py new file mode 100644 index 000000000..565c41228 --- /dev/null +++ b/contrib/pyln-spec/bolt7/pyln/spec/bolt7/bolt.py @@ -0,0 +1,5 @@ +from pyln.proto.message import MessageNamespace +from .csv import csv + + +namespace = MessageNamespace(csv_lines=csv) diff --git a/contrib/pyln-spec/bolt7/pyproject.toml b/contrib/pyln-spec/bolt7/pyproject.toml new file mode 100644 index 000000000..1062ae710 --- /dev/null +++ b/contrib/pyln-spec/bolt7/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "pyln-bolt7" +version = "1.0.186" +description = "BOLT7" +authors = ["Rusty Russell"] +license = "BSD-MIT" + +packages = [ + { include = "pyln/spec/bolt7" }, +] + +[tool.poetry.dependencies] +python = "^3.7" +pyln-proto = { path = "../../pyln-proto" } + +[tool.poetry.dev-dependencies] + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/contrib/pyln-spec/bolt7/requirements.txt b/contrib/pyln-spec/bolt7/requirements.txt deleted file mode 100644 index 16f309094..000000000 --- a/contrib/pyln-spec/bolt7/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyln-proto diff --git a/contrib/pyln-spec/bolt7/setup.py b/contrib/pyln-spec/bolt7/setup.py deleted file mode 100644 index c30d18d22..000000000 --- a/contrib/pyln-spec/bolt7/setup.py +++ /dev/null @@ -1,53 +0,0 @@ -from setuptools import setup -import io -import os - -base = os.path.dirname(__file__) -with io.open(os.path.join(base, 'requirements.txt'), encoding='utf-8') as f: - requirements = [r for r in f.read().split('\n') if len(r)] - - -def bolt_meta(bolt_num): - ctx = {} - pkg_dir = os.path.join(base, 'pyln', 'spec', 'bolt{}'.format(bolt_num)) - - files = ['gen_version.py', 'gen_csv_version.py', 'text.py'] - - for f in files: - f = os.path.join(pkg_dir, f) - with open(f, 'r') as fd: - exec(fd.read(), ctx) - - __version__ = '{__base_version__}.{__csv_version__}.{__post_version__}'.format(**ctx) - return { - 'description': ctx['desc'], - 'version': __version__, - } - - -def bolt_num(): - """Look into the pyln/spec/ directory to see which subpackages we provide. - """ - dirlist = os.listdir(os.path.join('pyln', 'spec')) - assert(len(dirlist) == 1) # Should only be the boltX directory - b = dirlist[0] - assert(b[:4] == 'bolt') - return int(b[4]) - - -boltnum = bolt_num() -meta = bolt_meta(boltnum) - -setup( - **meta, - name='pyln-bolt{}'.format(boltnum), - url='http://github.com/ElementsProject/lightning', - author='Rusty Russell', - author_email='rusty@rustcorp.com.au', - license='MIT', - packages=['pyln.spec.bolt{}'.format(boltnum)], - package_data={'pyln.proto.message': ['py.typed']}, - scripts=[], - zip_safe=True, - install_requires=requirements -)