devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] Require Python 3
@ 2024-08-11 15:02 Simon Glass
  2024-08-11 15:02 ` [PATCH 2/6] Tidy up some pylint warnings Simon Glass
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Simon Glass @ 2024-08-11 15:02 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: David Gibson, Gua Guo, Simon Glass

We don't need to support Python 2 anymore, so drop the comment and add
the minimum required version. Use version 3.8 since I am not sure that
it works on older versions and 3.7 has reached end-of-life.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 setup.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/setup.py b/setup.py
index 293bb6b..749bf1b 100755
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,6 @@
 #!/usr/bin/env python3
 # SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
 
-# While Python 3 is the default, it's also possible to invoke
-# this setup.py script with Python 2.
-
 """
 setup.py file for SWIG libfdt
 Copyright (C) 2017 Google, Inc.
@@ -60,6 +57,7 @@ setup(
     ext_modules=[libfdt_module],
     package_dir={'': os.path.join(srcdir, 'pylibfdt')},
     py_modules=['libfdt'],
+    python_requires=">=3.8",
 
     long_description=long_description,
     long_description_content_type="text/plain",
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] Tidy up some pylint warnings
  2024-08-11 15:02 [PATCH 1/6] Require Python 3 Simon Glass
@ 2024-08-11 15:02 ` Simon Glass
  2024-08-12  1:40   ` David Gibson
  2024-08-11 15:02 ` [PATCH 3/6] setup: Move version and full_description into a function Simon Glass
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2024-08-11 15:02 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: David Gibson, Gua Guo, Simon Glass

Resolve all the pylint warnings currently in setup.py

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 setup.py | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/setup.py b/setup.py
index 749bf1b..4e880e4 100755
--- a/setup.py
+++ b/setup.py
@@ -7,28 +7,32 @@ Copyright (C) 2017 Google, Inc.
 Written by Simon Glass <sjg@chromium.org>
 """
 
+import os
+import sys
+
 from setuptools import setup, Extension
 from setuptools.command.build_py import build_py as _build_py
 
-import os
-import re
-import sys
 
 srcdir = os.path.dirname(__file__)
 
-with open(os.path.join(srcdir, "README.md"), "r") as fh:
+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") as fh:
+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
+
+    Returns:
+        str: Directory to build in
+    """
     if '--top-builddir' in sys.argv:
         index = sys.argv.index('--top-builddir')
         sys.argv.pop(index)
         return sys.argv.pop(index)
-    else:
-        return srcdir
+    return srcdir
 
 top_builddir = get_top_builddir()
 
@@ -42,15 +46,18 @@ libfdt_module = Extension(
     swig_opts=['-I' + os.path.join(srcdir, 'libfdt')],
 )
 
-class build_py(_build_py):
+
+class BuildPy(_build_py):
+    """Small class to run the build_ext command"""
     def run(self):
         self.run_command("build_ext")
         return super().run()
 
+
 setup(
     name='libfdt',
     version=version,
-    cmdclass = {'build_py' : build_py},
+    cmdclass = {'build_py' : BuildPy},
     author='Simon Glass',
     author_email='sjg@chromium.org',
     description='Python binding for libfdt',
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] setup: Move version and full_description into a function
  2024-08-11 15:02 [PATCH 1/6] Require Python 3 Simon Glass
  2024-08-11 15:02 ` [PATCH 2/6] Tidy up some pylint warnings Simon Glass
@ 2024-08-11 15:02 ` Simon Glass
  2024-08-12  1:42   ` David Gibson
  2024-08-11 15:02 ` [PATCH 4/6] setup: Collect top-level code together Simon Glass
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2024-08-11 15:02 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: David Gibson, Gua Guo, Simon Glass

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

 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',
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] setup: Collect top-level code together
  2024-08-11 15:02 [PATCH 1/6] Require Python 3 Simon Glass
  2024-08-11 15:02 ` [PATCH 2/6] Tidy up some pylint warnings Simon Glass
  2024-08-11 15:02 ` [PATCH 3/6] setup: Move version and full_description into a function Simon Glass
@ 2024-08-11 15:02 ` Simon Glass
  2024-08-11 15:02 ` [PATCH 5/6] setup: Move setting of srcdir down to the bottom Simon Glass
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Simon Glass @ 2024-08-11 15:02 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: David Gibson, Gua Guo, Simon Glass

Move most of the top-level code together, with the classes and functions
above, for easier reading.

The srcdir is left where it is for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 setup.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/setup.py b/setup.py
index eb0963c..be3cf90 100755
--- a/setup.py
+++ b/setup.py
@@ -47,6 +47,15 @@ def get_top_builddir():
         return sys.argv.pop(index)
     return srcdir
 
+
+class BuildPy(_build_py):
+    """Small class to run the build_ext command"""
+    def run(self):
+        self.run_command("build_ext")
+        return super().run()
+
+
+version, long_description = scan_for_info(srcdir)
 top_builddir = get_top_builddir()
 
 libfdt_module = Extension(
@@ -60,14 +69,6 @@ libfdt_module = Extension(
 )
 
 
-class BuildPy(_build_py):
-    """Small class to run the build_ext command"""
-    def run(self):
-        self.run_command("build_ext")
-        return super().run()
-
-version, long_description = scan_for_info(srcdir)
-
 setup(
     name='libfdt',
     version=version,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] setup: Move setting of srcdir down to the bottom
  2024-08-11 15:02 [PATCH 1/6] Require Python 3 Simon Glass
                   ` (2 preceding siblings ...)
  2024-08-11 15:02 ` [PATCH 4/6] setup: Collect top-level code together Simon Glass
@ 2024-08-11 15:02 ` Simon Glass
  2024-08-12  1:50   ` David Gibson
  2024-08-11 15:02 ` [PATCH 6/6] setup: Add dependencies for Windows Simon Glass
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2024-08-11 15:02 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: David Gibson, Gua Guo, Simon Glass

Put this variable assignment next to the others. Pass it to
get_top_builddir() instead of relying on the global variable.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 setup.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/setup.py b/setup.py
index be3cf90..52844ce 100755
--- a/setup.py
+++ b/setup.py
@@ -14,8 +14,6 @@ from setuptools import setup, Extension
 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
 
@@ -35,9 +33,12 @@ def scan_for_info(srcdir):
     return version, long_description
 
 
-def get_top_builddir():
+def get_top_builddir(srcdir):
     """Figure out the top-level directory containing the source code
 
+    Args:
+        srcdir (str): Source-directory path
+
     Returns:
         str: Directory to build in
     """
@@ -55,8 +56,8 @@ class BuildPy(_build_py):
         return super().run()
 
 
+srcdir = os.path.dirname(__file__)
 version, long_description = scan_for_info(srcdir)
-top_builddir = get_top_builddir()
 
 libfdt_module = Extension(
     '_libfdt',
@@ -64,7 +65,7 @@ libfdt_module = Extension(
     define_macros=[('PY_SSIZE_T_CLEAN', None)],
     include_dirs=[os.path.join(srcdir, 'libfdt')],
     libraries=['fdt'],
-    library_dirs=[os.path.join(top_builddir, 'libfdt')],
+    library_dirs=[os.path.join(get_top_builddir(srcdir), 'libfdt')],
     swig_opts=['-I' + os.path.join(srcdir, 'libfdt')],
 )
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] setup: Add dependencies for Windows
  2024-08-11 15:02 [PATCH 1/6] Require Python 3 Simon Glass
                   ` (3 preceding siblings ...)
  2024-08-11 15:02 ` [PATCH 5/6] setup: Move setting of srcdir down to the bottom Simon Glass
@ 2024-08-11 15:02 ` Simon Glass
  2024-08-12  1:51   ` David Gibson
  2024-08-11 15:05 ` [PATCH 1/6] Require Python 3 Simon Glass
  2024-08-12  1:39 ` David Gibson
  6 siblings, 1 reply; 14+ messages in thread
From: Simon Glass @ 2024-08-11 15:02 UTC (permalink / raw)
  To: Devicetree Compiler; +Cc: David Gibson, Gua Guo, Simon Glass

From: Gua Guo <gua.guo@intel.com>

Windows apparently builds pylibfdt if swig is declared as a dependency
in the setup file. Otherwise it must be installed manually and Windows
does not sport a package manager, so this is hard for users.

This change seems to have no ill effects on Linux, at least.

So add a new setup_requires line.

Signed-off-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
This was picked up from:

https://github.com/devicetree-org/pylibfdt/pull/2

 setup.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/setup.py b/setup.py
index 52844ce..6efdae6 100755
--- a/setup.py
+++ b/setup.py
@@ -76,6 +76,7 @@ setup(
     cmdclass = {'build_py' : BuildPy},
     author='Simon Glass',
     author_email='sjg@chromium.org',
+    setup_requires = ['swig'],
     description='Python binding for libfdt',
     ext_modules=[libfdt_module],
     package_dir={'': os.path.join(srcdir, 'pylibfdt')},
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] Require Python 3
  2024-08-11 15:02 [PATCH 1/6] Require Python 3 Simon Glass
                   ` (4 preceding siblings ...)
  2024-08-11 15:02 ` [PATCH 6/6] setup: Add dependencies for Windows Simon Glass
@ 2024-08-11 15:05 ` Simon Glass
  2024-08-12  1:39 ` David Gibson
  6 siblings, 0 replies; 14+ messages in thread
From: Simon Glass @ 2024-08-11 15:05 UTC (permalink / raw)
  To: Devicetree Compiler, Rob Herring; +Cc: David Gibson, Gua Guo

+Rob Herring too in case you are not on this list

On Sun, 11 Aug 2024 at 09:02, Simon Glass <sjg@chromium.org> wrote:
>
> We don't need to support Python 2 anymore, so drop the comment and add
> the minimum required version. Use version 3.8 since I am not sure that
> it works on older versions and 3.7 has reached end-of-life.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  setup.py | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/setup.py b/setup.py
> index 293bb6b..749bf1b 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -1,9 +1,6 @@
>  #!/usr/bin/env python3
>  # SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
>
> -# While Python 3 is the default, it's also possible to invoke
> -# this setup.py script with Python 2.
> -
>  """
>  setup.py file for SWIG libfdt
>  Copyright (C) 2017 Google, Inc.
> @@ -60,6 +57,7 @@ setup(
>      ext_modules=[libfdt_module],
>      package_dir={'': os.path.join(srcdir, 'pylibfdt')},
>      py_modules=['libfdt'],
> +    python_requires=">=3.8",
>
>      long_description=long_description,
>      long_description_content_type="text/plain",
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/6] Require Python 3
  2024-08-11 15:02 [PATCH 1/6] Require Python 3 Simon Glass
                   ` (5 preceding siblings ...)
  2024-08-11 15:05 ` [PATCH 1/6] Require Python 3 Simon Glass
@ 2024-08-12  1:39 ` David Gibson
  6 siblings, 0 replies; 14+ messages in thread
From: David Gibson @ 2024-08-12  1:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Gua Guo

[-- Attachment #1: Type: text/plain, Size: 1336 bytes --]

On Sun, Aug 11, 2024 at 09:02:43AM -0600, Simon Glass wrote:
> We don't need to support Python 2 anymore, so drop the comment and add
> the minimum required version. Use version 3.8 since I am not sure that
> it works on older versions and 3.7 has reached end-of-life.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied, thanks.

> ---
> 
>  setup.py | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/setup.py b/setup.py
> index 293bb6b..749bf1b 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -1,9 +1,6 @@
>  #!/usr/bin/env python3
>  # SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
>  
> -# While Python 3 is the default, it's also possible to invoke
> -# this setup.py script with Python 2.
> -
>  """
>  setup.py file for SWIG libfdt
>  Copyright (C) 2017 Google, Inc.
> @@ -60,6 +57,7 @@ setup(
>      ext_modules=[libfdt_module],
>      package_dir={'': os.path.join(srcdir, 'pylibfdt')},
>      py_modules=['libfdt'],
> +    python_requires=">=3.8",
>  
>      long_description=long_description,
>      long_description_content_type="text/plain",

-- 
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/6] Tidy up some pylint warnings
  2024-08-11 15:02 ` [PATCH 2/6] Tidy up some pylint warnings Simon Glass
@ 2024-08-12  1:40   ` David Gibson
  0 siblings, 0 replies; 14+ messages in thread
From: David Gibson @ 2024-08-12  1:40 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Gua Guo

[-- Attachment #1: Type: text/plain, Size: 2397 bytes --]

On Sun, Aug 11, 2024 at 09:02:44AM -0600, Simon Glass wrote:
> Resolve all the pylint warnings currently in setup.py
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied, thanks.

> ---
> 
>  setup.py | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/setup.py b/setup.py
> index 749bf1b..4e880e4 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -7,28 +7,32 @@ Copyright (C) 2017 Google, Inc.
>  Written by Simon Glass <sjg@chromium.org>
>  """
>  
> +import os
> +import sys
> +
>  from setuptools import setup, Extension
>  from setuptools.command.build_py import build_py as _build_py
>  
> -import os
> -import re
> -import sys
>  
>  srcdir = os.path.dirname(__file__)
>  
> -with open(os.path.join(srcdir, "README.md"), "r") as fh:
> +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") as fh:
> +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
> +
> +    Returns:
> +        str: Directory to build in
> +    """
>      if '--top-builddir' in sys.argv:
>          index = sys.argv.index('--top-builddir')
>          sys.argv.pop(index)
>          return sys.argv.pop(index)
> -    else:
> -        return srcdir
> +    return srcdir
>  
>  top_builddir = get_top_builddir()
>  
> @@ -42,15 +46,18 @@ libfdt_module = Extension(
>      swig_opts=['-I' + os.path.join(srcdir, 'libfdt')],
>  )
>  
> -class build_py(_build_py):
> +
> +class BuildPy(_build_py):
> +    """Small class to run the build_ext command"""
>      def run(self):
>          self.run_command("build_ext")
>          return super().run()
>  
> +
>  setup(
>      name='libfdt',
>      version=version,
> -    cmdclass = {'build_py' : build_py},
> +    cmdclass = {'build_py' : BuildPy},
>      author='Simon Glass',
>      author_email='sjg@chromium.org',
>      description='Python binding for 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/6] setup: Move version and full_description into a function
  2024-08-11 15:02 ` [PATCH 3/6] setup: Move version and full_description into a function Simon Glass
@ 2024-08-12  1:42   ` David Gibson
  0 siblings, 0 replies; 14+ messages in thread
From: David Gibson @ 2024-08-12  1:42 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Gua Guo

[-- Attachment #1: Type: text/plain, Size: 1952 bytes --]

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@chromium.org>

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 5/6] setup: Move setting of srcdir down to the bottom
  2024-08-11 15:02 ` [PATCH 5/6] setup: Move setting of srcdir down to the bottom Simon Glass
@ 2024-08-12  1:50   ` David Gibson
  0 siblings, 0 replies; 14+ messages in thread
From: David Gibson @ 2024-08-12  1:50 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Gua Guo

[-- Attachment #1: Type: text/plain, Size: 1979 bytes --]

On Sun, Aug 11, 2024 at 09:02:47AM -0600, Simon Glass wrote:
> Put this variable assignment next to the others. Pass it to
> get_top_builddir() instead of relying on the global variable.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied, thanks.

> ---
> 
>  setup.py | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/setup.py b/setup.py
> index be3cf90..52844ce 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -14,8 +14,6 @@ from setuptools import setup, Extension
>  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
>  
> @@ -35,9 +33,12 @@ def scan_for_info(srcdir):
>      return version, long_description
>  
>  
> -def get_top_builddir():
> +def get_top_builddir(srcdir):
>      """Figure out the top-level directory containing the source code
>  
> +    Args:
> +        srcdir (str): Source-directory path
> +
>      Returns:
>          str: Directory to build in
>      """
> @@ -55,8 +56,8 @@ class BuildPy(_build_py):
>          return super().run()
>  
>  
> +srcdir = os.path.dirname(__file__)
>  version, long_description = scan_for_info(srcdir)
> -top_builddir = get_top_builddir()
>  
>  libfdt_module = Extension(
>      '_libfdt',
> @@ -64,7 +65,7 @@ libfdt_module = Extension(
>      define_macros=[('PY_SSIZE_T_CLEAN', None)],
>      include_dirs=[os.path.join(srcdir, 'libfdt')],
>      libraries=['fdt'],
> -    library_dirs=[os.path.join(top_builddir, 'libfdt')],
> +    library_dirs=[os.path.join(get_top_builddir(srcdir), 'libfdt')],
>      swig_opts=['-I' + os.path.join(srcdir, '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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] setup: Add dependencies for Windows
  2024-08-11 15:02 ` [PATCH 6/6] setup: Add dependencies for Windows Simon Glass
@ 2024-08-12  1:51   ` David Gibson
  2024-08-12  2:01     ` David Gibson
  0 siblings, 1 reply; 14+ messages in thread
From: David Gibson @ 2024-08-12  1:51 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Gua Guo

[-- Attachment #1: Type: text/plain, Size: 1447 bytes --]

On Sun, Aug 11, 2024 at 09:02:48AM -0600, Simon Glass wrote:
> From: Gua Guo <gua.guo@intel.com>
> 
> Windows apparently builds pylibfdt if swig is declared as a dependency
> in the setup file. Otherwise it must be installed manually and Windows
> does not sport a package manager, so this is hard for users.
> 
> This change seems to have no ill effects on Linux, at least.
> 
> So add a new setup_requires line.
> 
> Signed-off-by: Gua Guo <gua.guo@intel.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied.

We do have windows build in our github actions.  It would be great if
a test for building pylibfdt properly there were added.

> ---
> This was picked up from:
> 
> https://github.com/devicetree-org/pylibfdt/pull/2
> 
>  setup.py | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/setup.py b/setup.py
> index 52844ce..6efdae6 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -76,6 +76,7 @@ setup(
>      cmdclass = {'build_py' : BuildPy},
>      author='Simon Glass',
>      author_email='sjg@chromium.org',
> +    setup_requires = ['swig'],
>      description='Python binding for libfdt',
>      ext_modules=[libfdt_module],
>      package_dir={'': os.path.join(srcdir, 'pylibfdt')},

-- 
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] setup: Add dependencies for Windows
  2024-08-12  1:51   ` David Gibson
@ 2024-08-12  2:01     ` David Gibson
  2024-08-14  2:15       ` Simon Glass
  0 siblings, 1 reply; 14+ messages in thread
From: David Gibson @ 2024-08-12  2:01 UTC (permalink / raw)
  To: Simon Glass; +Cc: Devicetree Compiler, Gua Guo

[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]

On Mon, Aug 12, 2024 at 11:51:05AM +1000, David Gibson wrote:
> On Sun, Aug 11, 2024 at 09:02:48AM -0600, Simon Glass wrote:
> > From: Gua Guo <gua.guo@intel.com>
> > 
> > Windows apparently builds pylibfdt if swig is declared as a dependency
> > in the setup file. Otherwise it must be installed manually and Windows
> > does not sport a package manager, so this is hard for users.
> > 
> > This change seems to have no ill effects on Linux, at least.
> > 
> > So add a new setup_requires line.
> > 
> > Signed-off-by: Gua Guo <gua.guo@intel.com>
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> 
> Applied.

Oops, spoke too soon.  While this works locally for me, it breaks on
the github CI.  See:

    https://github.com/dgibson/dtc/actions/runs/10344711112

> We do have windows build in our github actions.  It would be great if
> a test for building pylibfdt properly there were added.

This remains true, once the Linux breakage is fixed.

-- 
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] setup: Add dependencies for Windows
  2024-08-12  2:01     ` David Gibson
@ 2024-08-14  2:15       ` Simon Glass
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Glass @ 2024-08-14  2:15 UTC (permalink / raw)
  To: David Gibson; +Cc: Devicetree Compiler, Gua Guo

Hi David,

On Sun, 11 Aug 2024 at 20:01, David Gibson <david@gibson.dropbear.id.au> wrote:
>
> On Mon, Aug 12, 2024 at 11:51:05AM +1000, David Gibson wrote:
> > On Sun, Aug 11, 2024 at 09:02:48AM -0600, Simon Glass wrote:
> > > From: Gua Guo <gua.guo@intel.com>
> > >
> > > Windows apparently builds pylibfdt if swig is declared as a dependency
> > > in the setup file. Otherwise it must be installed manually and Windows
> > > does not sport a package manager, so this is hard for users.
> > >
> > > This change seems to have no ill effects on Linux, at least.
> > >
> > > So add a new setup_requires line.
> > >
> > > Signed-off-by: Gua Guo <gua.guo@intel.com>
> > > Signed-off-by: Simon Glass <sjg@chromium.org>
> >
> > Applied.
>
> Oops, spoke too soon.  While this works locally for me, it breaks on
> the github CI.  See:
>
>     https://github.com/dgibson/dtc/actions/runs/10344711112
>
> > We do have windows build in our github actions.  It would be great if
> > a test for building pylibfdt properly there were added.
>
> This remains true, once the Linux breakage is fixed.

Thanks for that. We'll try to figure out that MSYS2 error.

Regards,
Simon

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-08-14  2:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-11 15:02 [PATCH 1/6] Require Python 3 Simon Glass
2024-08-11 15:02 ` [PATCH 2/6] Tidy up some pylint warnings Simon Glass
2024-08-12  1:40   ` David Gibson
2024-08-11 15:02 ` [PATCH 3/6] setup: Move version and full_description into a function Simon Glass
2024-08-12  1:42   ` David Gibson
2024-08-11 15:02 ` [PATCH 4/6] setup: Collect top-level code together Simon Glass
2024-08-11 15:02 ` [PATCH 5/6] setup: Move setting of srcdir down to the bottom Simon Glass
2024-08-12  1:50   ` David Gibson
2024-08-11 15:02 ` [PATCH 6/6] setup: Add dependencies for Windows Simon Glass
2024-08-12  1:51   ` David Gibson
2024-08-12  2:01     ` David Gibson
2024-08-14  2:15       ` Simon Glass
2024-08-11 15:05 ` [PATCH 1/6] Require Python 3 Simon Glass
2024-08-12  1:39 ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).