pyln: Migrate pyln-bolt7 to PEP517 (poetry)

This commit is contained in:
Christian Decker 2022-02-21 19:43:40 +01:00 committed by Rusty Russell
parent 74fd685219
commit b0f8a99310
6 changed files with 51 additions and 56 deletions

1
contrib/pyln-spec/bolt7/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
poetry.lock

View file

@ -1 +0,0 @@
../../../../subinit.py

View file

@ -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)

View file

@ -1 +0,0 @@
../../../../bolt.py

View file

@ -0,0 +1,5 @@
from pyln.proto.message import MessageNamespace
from .csv import csv
namespace = MessageNamespace(csv_lines=csv)

View file

@ -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"

View file

@ -1 +0,0 @@
pyln-proto

View file

@ -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
)