Re: [PATCH 3/6] setup: Move version and full_description into a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sun, Aug 11, 2024 at 09:02:45AM -0600, Simon Glass wrote:
> 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@xxxxxxxxxxxx>

Applied, thanks.

> ---
> 
>  setup.py | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/setup.py b/setup.py
> index 4e880e4..eb0963c 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -16,11 +16,24 @@ from setuptools.command.build_py import build_py as _build_py
>  
>  srcdir = os.path.dirname(__file__)
>  
> -with open(os.path.join(srcdir, "README.md"), "r", encoding='utf-8') as fh:
> -    long_description = fh.read()
> +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()
> +
> +    return version, long_description
>  
> -with open(os.path.join(srcdir, "VERSION.txt"), "r", encoding='utf-8') as fh:
> -    version = fh.readline().strip()
>  
>  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',

-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux