Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] utils/scanpypi: supply package name to setup() when not provided
@ 2022-09-18 19:48 erichiggins
  2023-08-26 21:39 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 10+ messages in thread
From: erichiggins @ 2022-09-18 19:48 UTC (permalink / raw)
  To: buildroot

Issue description:
The `utils/scanpypi` script makes an erroneous assumption that Python
packages will call `setup()` with the `name` argument. It's not
required and not often used. This causes the script to fail to load
many packages from Pypi.
 For example,  `./utils/scanpypi wheel` returns the following error:
> `Error: Could not install package wheel: 'name'`

Why it happens:
In plain english, the scanpypi` script assumes that a `name` argument
will be supplied to the `setup` call within the `setup.py` of a Python
package. If it's not there, then the script breaks.
Technical details: The `distutils.core.setup` and `setuptools.setup`
calls are wrapped by `setup_decorator` then monkey-patched after
import to set the `BuildrootPackage.setup_args` based on the `args`
and `kwargs` which were supplied by the package's call to `setup`.
This fails with `KeyError` when there are none.

One solution, which I've provided here as a patch, is to define
`BuildrootPackage.setup_args['name']` upon object instantiation using
the provided `real_name` variable, then using that as the fallback
option in the `setup_decorator`.

How I fixed it:
I store the package name as provided from the command line and use it
as a fallback option in case the-way-it-works-now doesn't work.

Signed-off-by: Eric Higgins <erichiggins@gmail.com>
---
 utils/scanpypi | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/utils/scanpypi b/utils/scanpypi
index 452b4a3fc3..a5522a879e 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -58,8 +58,9 @@ def setup_decorator(func, method):
     def closure(*args, **kwargs):
         # Any python packages calls its setup function to be installed.
         # Argument 'name' of this setup function is the package's name
-        BuildrootPackage.setup_args[kwargs['name']] = kwargs
-        BuildrootPackage.setup_args[kwargs['name']]['method'] = method
+        name = kwargs.get('name', BuildrootPackage.setup_args['name'])
+        BuildrootPackage.setup_args[name] = kwargs
+        BuildrootPackage.setup_args[name]['method'] = method
     return closure

 # monkey patch
@@ -147,6 +148,7 @@ class BuildrootPackage():
         self.url = None
         self.version = None
         self.license_files = []
+        self.setup_args['name'] = self.real_name

     def fetch_package_info(self):
         """
--
2.25.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [Buildroot] [PATCH 1/1] utils/scanpypi: supply package name to setup() when not provided
@ 2022-09-12 16:28 erichiggins
  2022-09-12 20:34 ` Yann E. MORIN
  0 siblings, 1 reply; 10+ messages in thread
From: erichiggins @ 2022-09-12 16:28 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Eric Higgins <erichiggins@gmail.com>
---
 utils/scanpypi | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/utils/scanpypi b/utils/scanpypi
index 452b4a3fc3..a5522a879e 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -58,8 +58,9 @@ def setup_decorator(func, method):
     def closure(*args, **kwargs):
         # Any python packages calls its setup function to be installed.
         # Argument 'name' of this setup function is the package's name
-        BuildrootPackage.setup_args[kwargs['name']] = kwargs
-        BuildrootPackage.setup_args[kwargs['name']]['method'] = method
+        name = kwargs.get('name', BuildrootPackage.setup_args['name'])
+        BuildrootPackage.setup_args[name] = kwargs
+        BuildrootPackage.setup_args[name]['method'] = method
     return closure

 # monkey patch
@@ -147,6 +148,7 @@ class BuildrootPackage():
         self.url = None
         self.version = None
         self.license_files = []
+        self.setup_args['name'] = self.real_name

     def fetch_package_info(self):
         """
-- 
2.25.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2023-08-27 21:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-18 19:48 [Buildroot] [PATCH 1/1] utils/scanpypi: supply package name to setup() when not provided erichiggins
2023-08-26 21:39 ` Thomas Petazzoni via buildroot
2023-08-27  7:03   ` James Hilliard
2023-08-27 21:28   ` erichiggins
  -- strict thread matches above, loose matches on Subject: below --
2022-09-12 16:28 erichiggins
2022-09-12 20:34 ` Yann E. MORIN
2022-09-12 21:05   ` Marcus Hoffmann
2022-09-12 21:34     ` erichiggins
2022-09-18 16:00       ` Yann E. MORIN
2022-09-18 19:32         ` erichiggins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox