pyln: Change the setup.py file not to import the package

This would lead to errors about missing dependencies when attempting
to install using `pyhon setup.py install`. This is because the
`setup.py` file effectively is the manifest file used to discover
which dependencies are needed, so when using it to detect dependencies
we obviously don't have them yet.

See https://packaging.python.org/guides/single-sourcing-package-version/
This commit is contained in:
Christian Decker 2021-03-19 14:32:16 +01:00 committed by Rusty Russell
parent 1bebdfdd5f
commit 6b0a7b173c

View file

@ -1,16 +1,34 @@
from setuptools import setup
from pyln.proto import __version__
import codecs
import io
import os.path
with io.open('README.md', encoding='utf-8') as f:
long_description = f.read()
with io.open('requirements.txt', encoding='utf-8') as f:
requirements = [r for r in f.read().split('\n') if len(r)]
def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()
def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")
setup(name='pyln-proto',
version=__version__,
version=get_version("pyln/proto/__init__.py"),
description='Pure python implementation of the Lightning Network protocol',
long_description=long_description,
long_description_content_type='text/markdown',