mirror of
https://github.com/dgibson/dtc.git
synced 2026-10-10 08:03:00 -04:00
setup: Move version and full_description into a function
Do this processing in a function and return the result, to reduce the amount of code at the top level. Signed-off-by: Simon Glass <sjg@chromium.org> Message-ID: <20240811150248.7537-3-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
78b6a85c11
commit
7e5a889840
1 changed files with 18 additions and 4 deletions
18
setup.py
18
setup.py
|
|
@ -16,11 +16,24 @@ from setuptools.command.build_py import build_py as _build_py
|
|||
|
||||
srcdir = os.path.dirname(__file__)
|
||||
|
||||
def scan_for_info(srcdir):
|
||||
"""Scan for the version and long_description fields
|
||||
|
||||
Args:
|
||||
srcdir (str): Source-directory path
|
||||
|
||||
Returns: tuple
|
||||
str: Full description (contents of README.md)
|
||||
str: Version string
|
||||
"""
|
||||
with open(os.path.join(srcdir, "VERSION.txt"), "r", encoding='utf-8') as fh:
|
||||
version = fh.readline().strip()
|
||||
|
||||
with open(os.path.join(srcdir, "README.md"), "r", encoding='utf-8') as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
with open(os.path.join(srcdir, "VERSION.txt"), "r", encoding='utf-8') as fh:
|
||||
version = fh.readline().strip()
|
||||
return version, long_description
|
||||
|
||||
|
||||
def get_top_builddir():
|
||||
"""Figure out the top-level directory containing the source code
|
||||
|
|
@ -53,6 +66,7 @@ class BuildPy(_build_py):
|
|||
self.run_command("build_ext")
|
||||
return super().run()
|
||||
|
||||
version, long_description = scan_for_info(srcdir)
|
||||
|
||||
setup(
|
||||
name='libfdt',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue