From 60135cf9ba6525e0932670f00c7a2f752b20e381 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sat, 26 Feb 2022 11:31:59 +0100 Subject: [PATCH] pyln: MIgrate the BOLT packages to poetry / PEP 517 --- contrib/pyln-spec/bolt.py | 5 -- contrib/pyln-spec/bolt1/.gitignore | 1 + .../bolt1/pyln/spec/bolt1/__init__.py | 26 ++++++++- .../pyln-spec/bolt1/pyln/spec/bolt1/bolt.py | 6 ++- contrib/pyln-spec/bolt1/pyproject.toml | 20 +++++++ contrib/pyln-spec/bolt1/requirements.txt | 1 - contrib/pyln-spec/bolt1/setup.py | 53 ------------------- contrib/pyln-spec/bolt2/.gitignore | 1 + .../bolt2/pyln/spec/bolt2/__init__.py | 26 ++++++++- .../pyln-spec/bolt2/pyln/spec/bolt2/bolt.py | 6 ++- contrib/pyln-spec/bolt2/pyproject.toml | 20 +++++++ contrib/pyln-spec/bolt2/requirements.txt | 1 - contrib/pyln-spec/bolt2/setup.py | 53 ------------------- contrib/pyln-spec/bolt4/.gitignore | 1 + .../bolt4/pyln/spec/bolt4/__init__.py | 26 ++++++++- .../pyln-spec/bolt4/pyln/spec/bolt4/bolt.py | 6 ++- contrib/pyln-spec/bolt4/pyproject.toml | 20 +++++++ contrib/pyln-spec/bolt4/requirements.txt | 1 - contrib/pyln-spec/bolt4/setup.py | 53 ------------------- contrib/pyln-spec/subinit.py | 25 --------- 20 files changed, 153 insertions(+), 198 deletions(-) delete mode 100644 contrib/pyln-spec/bolt.py create mode 100644 contrib/pyln-spec/bolt1/.gitignore mode change 120000 => 100644 contrib/pyln-spec/bolt1/pyln/spec/bolt1/__init__.py mode change 120000 => 100644 contrib/pyln-spec/bolt1/pyln/spec/bolt1/bolt.py create mode 100644 contrib/pyln-spec/bolt1/pyproject.toml delete mode 100644 contrib/pyln-spec/bolt1/requirements.txt delete mode 100644 contrib/pyln-spec/bolt1/setup.py create mode 100644 contrib/pyln-spec/bolt2/.gitignore mode change 120000 => 100644 contrib/pyln-spec/bolt2/pyln/spec/bolt2/__init__.py mode change 120000 => 100644 contrib/pyln-spec/bolt2/pyln/spec/bolt2/bolt.py create mode 100644 contrib/pyln-spec/bolt2/pyproject.toml delete mode 100644 contrib/pyln-spec/bolt2/requirements.txt delete mode 100644 contrib/pyln-spec/bolt2/setup.py create mode 100644 contrib/pyln-spec/bolt4/.gitignore mode change 120000 => 100644 contrib/pyln-spec/bolt4/pyln/spec/bolt4/__init__.py mode change 120000 => 100644 contrib/pyln-spec/bolt4/pyln/spec/bolt4/bolt.py create mode 100644 contrib/pyln-spec/bolt4/pyproject.toml delete mode 100644 contrib/pyln-spec/bolt4/requirements.txt delete mode 100644 contrib/pyln-spec/bolt4/setup.py delete mode 100644 contrib/pyln-spec/subinit.py diff --git a/contrib/pyln-spec/bolt.py b/contrib/pyln-spec/bolt.py deleted file mode 100644 index 565c41228..000000000 --- a/contrib/pyln-spec/bolt.py +++ /dev/null @@ -1,5 +0,0 @@ -from pyln.proto.message import MessageNamespace -from .csv import csv - - -namespace = MessageNamespace(csv_lines=csv) diff --git a/contrib/pyln-spec/bolt1/.gitignore b/contrib/pyln-spec/bolt1/.gitignore new file mode 100644 index 000000000..c04bc49f7 --- /dev/null +++ b/contrib/pyln-spec/bolt1/.gitignore @@ -0,0 +1 @@ +poetry.lock diff --git a/contrib/pyln-spec/bolt1/pyln/spec/bolt1/__init__.py b/contrib/pyln-spec/bolt1/pyln/spec/bolt1/__init__.py deleted file mode 120000 index 52f300f8a..000000000 --- a/contrib/pyln-spec/bolt1/pyln/spec/bolt1/__init__.py +++ /dev/null @@ -1 +0,0 @@ -../../../../subinit.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt1/pyln/spec/bolt1/__init__.py b/contrib/pyln-spec/bolt1/pyln/spec/bolt1/__init__.py new file mode 100644 index 000000000..749979a1e --- /dev/null +++ b/contrib/pyln-spec/bolt1/pyln/spec/bolt1/__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/bolt1/pyln/spec/bolt1/bolt.py b/contrib/pyln-spec/bolt1/pyln/spec/bolt1/bolt.py deleted file mode 120000 index c22b879fc..000000000 --- a/contrib/pyln-spec/bolt1/pyln/spec/bolt1/bolt.py +++ /dev/null @@ -1 +0,0 @@ -../../../../bolt.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt1/pyln/spec/bolt1/bolt.py b/contrib/pyln-spec/bolt1/pyln/spec/bolt1/bolt.py new file mode 100644 index 000000000..565c41228 --- /dev/null +++ b/contrib/pyln-spec/bolt1/pyln/spec/bolt1/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/bolt1/pyproject.toml b/contrib/pyln-spec/bolt1/pyproject.toml new file mode 100644 index 000000000..903c33114 --- /dev/null +++ b/contrib/pyln-spec/bolt1/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "pyln-bolt1" +version = "1.0.1.187" +description = "" +authors = ["Rusty Russell <@rustyrussell>"] +license = "MIT" + +packages = [ + { include = "pyln/spec/bolt1" }, +] + +[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/bolt1/requirements.txt b/contrib/pyln-spec/bolt1/requirements.txt deleted file mode 100644 index c863b024f..000000000 --- a/contrib/pyln-spec/bolt1/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyln-proto >= 0.9.3 diff --git a/contrib/pyln-spec/bolt1/setup.py b/contrib/pyln-spec/bolt1/setup.py deleted file mode 100644 index c30d18d22..000000000 --- a/contrib/pyln-spec/bolt1/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 -) diff --git a/contrib/pyln-spec/bolt2/.gitignore b/contrib/pyln-spec/bolt2/.gitignore new file mode 100644 index 000000000..c04bc49f7 --- /dev/null +++ b/contrib/pyln-spec/bolt2/.gitignore @@ -0,0 +1 @@ +poetry.lock diff --git a/contrib/pyln-spec/bolt2/pyln/spec/bolt2/__init__.py b/contrib/pyln-spec/bolt2/pyln/spec/bolt2/__init__.py deleted file mode 120000 index 52f300f8a..000000000 --- a/contrib/pyln-spec/bolt2/pyln/spec/bolt2/__init__.py +++ /dev/null @@ -1 +0,0 @@ -../../../../subinit.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt2/pyln/spec/bolt2/__init__.py b/contrib/pyln-spec/bolt2/pyln/spec/bolt2/__init__.py new file mode 100644 index 000000000..749979a1e --- /dev/null +++ b/contrib/pyln-spec/bolt2/pyln/spec/bolt2/__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/bolt2/pyln/spec/bolt2/bolt.py b/contrib/pyln-spec/bolt2/pyln/spec/bolt2/bolt.py deleted file mode 120000 index c22b879fc..000000000 --- a/contrib/pyln-spec/bolt2/pyln/spec/bolt2/bolt.py +++ /dev/null @@ -1 +0,0 @@ -../../../../bolt.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt2/pyln/spec/bolt2/bolt.py b/contrib/pyln-spec/bolt2/pyln/spec/bolt2/bolt.py new file mode 100644 index 000000000..565c41228 --- /dev/null +++ b/contrib/pyln-spec/bolt2/pyln/spec/bolt2/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/bolt2/pyproject.toml b/contrib/pyln-spec/bolt2/pyproject.toml new file mode 100644 index 000000000..14895c170 --- /dev/null +++ b/contrib/pyln-spec/bolt2/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "pyln-bolt2" +version = "1.0.1.187" +description = "A pure python implementation of BOLT2" +authors = ["Rusty Russell <@rustyrussell>"] +license = "MIT" + +packages = [ + { include = "pyln/spec/bolt2" }, +] + +[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/bolt2/requirements.txt b/contrib/pyln-spec/bolt2/requirements.txt deleted file mode 100644 index c863b024f..000000000 --- a/contrib/pyln-spec/bolt2/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyln-proto >= 0.9.3 diff --git a/contrib/pyln-spec/bolt2/setup.py b/contrib/pyln-spec/bolt2/setup.py deleted file mode 100644 index c30d18d22..000000000 --- a/contrib/pyln-spec/bolt2/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 -) diff --git a/contrib/pyln-spec/bolt4/.gitignore b/contrib/pyln-spec/bolt4/.gitignore new file mode 100644 index 000000000..c04bc49f7 --- /dev/null +++ b/contrib/pyln-spec/bolt4/.gitignore @@ -0,0 +1 @@ +poetry.lock diff --git a/contrib/pyln-spec/bolt4/pyln/spec/bolt4/__init__.py b/contrib/pyln-spec/bolt4/pyln/spec/bolt4/__init__.py deleted file mode 120000 index 52f300f8a..000000000 --- a/contrib/pyln-spec/bolt4/pyln/spec/bolt4/__init__.py +++ /dev/null @@ -1 +0,0 @@ -../../../../subinit.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt4/pyln/spec/bolt4/__init__.py b/contrib/pyln-spec/bolt4/pyln/spec/bolt4/__init__.py new file mode 100644 index 000000000..749979a1e --- /dev/null +++ b/contrib/pyln-spec/bolt4/pyln/spec/bolt4/__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/bolt4/pyln/spec/bolt4/bolt.py b/contrib/pyln-spec/bolt4/pyln/spec/bolt4/bolt.py deleted file mode 120000 index c22b879fc..000000000 --- a/contrib/pyln-spec/bolt4/pyln/spec/bolt4/bolt.py +++ /dev/null @@ -1 +0,0 @@ -../../../../bolt.py \ No newline at end of file diff --git a/contrib/pyln-spec/bolt4/pyln/spec/bolt4/bolt.py b/contrib/pyln-spec/bolt4/pyln/spec/bolt4/bolt.py new file mode 100644 index 000000000..565c41228 --- /dev/null +++ b/contrib/pyln-spec/bolt4/pyln/spec/bolt4/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/bolt4/pyproject.toml b/contrib/pyln-spec/bolt4/pyproject.toml new file mode 100644 index 000000000..33afd320c --- /dev/null +++ b/contrib/pyln-spec/bolt4/pyproject.toml @@ -0,0 +1,20 @@ +[tool.poetry] +name = "pyln-bolt4" +version = "1.0.1.187" +description = "A pure python implementation of BOLT4" +authors = ["Rusty Russell <@rustyrussell>"] +license = "MIT" + +packages = [ + { include = "pyln/spec/bolt4" }, +] + +[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/bolt4/requirements.txt b/contrib/pyln-spec/bolt4/requirements.txt deleted file mode 100644 index c863b024f..000000000 --- a/contrib/pyln-spec/bolt4/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyln-proto >= 0.9.3 diff --git a/contrib/pyln-spec/bolt4/setup.py b/contrib/pyln-spec/bolt4/setup.py deleted file mode 100644 index c30d18d22..000000000 --- a/contrib/pyln-spec/bolt4/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 -) diff --git a/contrib/pyln-spec/subinit.py b/contrib/pyln-spec/subinit.py deleted file mode 100644 index 749979a1e..000000000 --- a/contrib/pyln-spec/subinit.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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)