Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: erichiggins@gmail.com
Cc: James Hilliard <james.hilliard1@gmail.com>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] utils/scanpypi: supply package name to setup() when not provided
Date: Sat, 26 Aug 2023 23:39:15 +0200	[thread overview]
Message-ID: <20230826233915.2e1a535a@windsurf> (raw)
In-Reply-To: <CAHfxMJ6M-R8oHY-8ChxdhanpcL2_04mYARHSxW=YS_gw7Npctg@mail.gmail.com>

Hello Eric,

+James in Cc.

Sorry for the super long lag.

On Sun, 18 Sep 2022 12:48:31 -0700
erichiggins@gmail.com wrote:

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

Do you have a current example that fails due to this? The wheel package
does pass a name= attribute to its setup() function, and it has been
doing this for many years. Looking at the initial commit of
https://github.com/pypa/wheel:

diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..09a138e
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,33 @@
+import os
+
+from setuptools import setup
+
+here = os.path.abspath(os.path.dirname(__file__))
+README = open(os.path.join(here, 'README.txt')).read()
+CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
+
+setup(name='wheel',
+      version='0.1',
+      description='A built-package installer for Python.',
+      long_description=README + '\n\n' +  CHANGES,
+      classifiers=[
+        "Development Status :: 1 - ",
+        "Intended Audience :: Developers",

So I'm a bit puzzled at how you found a wheel package that doesn't pass
"name" in its setup() arguments.

> 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

I'm not a big fan of shoehorning 'name' in setup_args, which as I
understand it is a dict that should contain a single key named after
the package. Perhaps it would be better to make "self.real_name" a
class variable rather than an instance variable, just like setup_args
is already, so that setup_decorator can access it. If I understand the
current implementation correctly, it anyway expects the
BuildrootPackage() class to have only one instance.

What do you think?

Best regards,

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2023-08-26 21:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230826233915.2e1a535a@windsurf \
    --to=buildroot@buildroot.org \
    --cc=erichiggins@gmail.com \
    --cc=james.hilliard1@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox