public inbox for buildroot@busybox.net
 help / color / mirror / Atom feed
From: Flaviu Nistor <flaviu.nistor@gmail.com>
To: buildroot@buildroot.org
Cc: Flaviu Nistor <flaviu.nistor@gmail.com>
Subject: [Buildroot] [PATCH v2 1/1] utils/scanpypi: workaround for pypi project names
Date: Thu,  9 Apr 2026 18:43:23 +0300	[thread overview]
Message-ID: <20260409154323.6842-2-flaviu.nistor@gmail.com> (raw)
In-Reply-To: <20260409154323.6842-1-flaviu.nistor@gmail.com>

Get the pypi name from the .mk file if it exist. This solves
an issue in cases when there is a different buildroot package
name compared to the pypi project name (e.g. smmap2 -> smmap).
Since it is not intended to change the buildroot package name,
this is a workaround in order to use the scanpypi utility for
this packages and still get correct generated files.

Signed-off-by: Flaviu Nistor <flaviu.nistor@gmail.com>
---
 utils/scanpypi | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/utils/scanpypi b/utils/scanpypi
index 61879e39d4..afdc00c80b 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -216,8 +216,25 @@ class BuildrootPackage():
         """
         Fetch a package's metadata from the python package index
         """
+        # If a .mk file already exists for this package, try to extract the
+        # upstream PyPI name from the _SOURCE variable. This handles cases
+        # where the Buildroot package name differs from the PyPI project name
+        # (e.g. smmap2 buildroot package is smmap on PyPI).
+        buildroot_package_folder = os.path.join('package', self.buildroot_name)
+        pypi_name = self.real_name
+        mk_file = os.path.join(buildroot_package_folder, self.buildroot_name + '.mk')
+        if os.path.isfile(mk_file):
+            source_re = re.compile(r'^' + self.mk_name + r'_SOURCE\s*=\s*(.+)$')
+            with open(mk_file) as mk_fh:
+                for line in mk_fh:
+                    match = source_re.match(line)
+                    if match:
+                        value = match.group(1).strip()
+                        if '-$(' in value:
+                            pypi_name = value.split('-$(')[0]
+                            break
         self.metadata_url = 'https://pypi.org/pypi/{pkg}/json'.format(
-            pkg=self.real_name)
+            pkg=pypi_name)
         try:
             pkg_json = urllib.request.urlopen(self.metadata_url).read().decode()
         except urllib.error.HTTPError as error:
@@ -225,13 +242,13 @@ class BuildrootPackage():
             print('ERROR: Could not find package {pkg}.\n'
                   'Check syntax inside the python package index:\n'
                   'https://pypi.python.org/pypi/ '
-                  .format(pkg=self.real_name))
+                  .format(pkg=pypi_name))
             raise
         except urllib.error.URLError:
             print('ERROR: Could not find package {pkg}.\n'
                   'Check syntax inside the python package index:\n'
                   'https://pypi.python.org/pypi/ '
-                  .format(pkg=self.real_name))
+                  .format(pkg=pypi_name))
             raise
         self.metadata = json.loads(pkg_json)
         self.version = self.metadata['info']['version']
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2026-04-09 15:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 15:43 [Buildroot] [PATCH v2 0/1] utils/scanpypi: workaround for pypi project names Flaviu Nistor
2026-04-09 15:43 ` Flaviu Nistor [this message]

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=20260409154323.6842-2-flaviu.nistor@gmail.com \
    --to=flaviu.nistor@gmail.com \
    --cc=buildroot@buildroot.org \
    /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