Skip to content

Commit 6b0a7b1

Browse files
cdeckerrustyrussell
authored andcommitted
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/
1 parent 1bebdfd commit 6b0a7b1

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

contrib/pyln-proto/setup.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
11
from setuptools import setup
2-
from pyln.proto import __version__
2+
import codecs
33
import io
4+
import os.path
45

56

67
with io.open('README.md', encoding='utf-8') as f:
78
long_description = f.read()
89

10+
911
with io.open('requirements.txt', encoding='utf-8') as f:
1012
requirements = [r for r in f.read().split('\n') if len(r)]
1113

14+
15+
def read(rel_path):
16+
here = os.path.abspath(os.path.dirname(__file__))
17+
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
18+
return fp.read()
19+
20+
21+
def get_version(rel_path):
22+
for line in read(rel_path).splitlines():
23+
if line.startswith('__version__'):
24+
delim = '"' if '"' in line else "'"
25+
return line.split(delim)[1]
26+
else:
27+
raise RuntimeError("Unable to find version string.")
28+
29+
1230
setup(name='pyln-proto',
13-
version=__version__,
31+
version=get_version("pyln/proto/__init__.py"),
1432
description='Pure python implementation of the Lightning Network protocol',
1533
long_description=long_description,
1634
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)