From: James Hilliard <james.hilliard1@gmail.com>
To: buildroot@buildroot.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
James Hilliard <james.hilliard1@gmail.com>,
Thomas Perale <thomas.perale@mind.be>,
Ricardo Martincoski <ricardo.martincoski@datacom.com.br>
Subject: [Buildroot] [PATCH v2 2/3] package/pkg-python: derive PyPI site from blake2b-256 hash
Date: Wed, 17 Jun 2026 11:42:07 -0600 [thread overview]
Message-ID: <20260617174208.3968183-2-james.hilliard1@gmail.com> (raw)
In-Reply-To: <20260617174208.3968183-1-james.hilliard1@gmail.com>
Python packages downloaded from PyPI currently store the complete
files.pythonhosted.org package path in their .mk file. That path is
hash-based, so it changes for every version bump and adds churn to
updates and backports.
When a Python package does not define _SITE, derive the hash-based
files.pythonhosted.org site from the blake2b-256 entry matching the
package source archive in the package .hash file before the generic
package infrastructure validates _SITE.
Follow the usual target/host fallback pattern for _SITE, and raise an
explicit error if no hash file is available or if the hash file does not
contain a matching blake2b-256 entry.
Update scanpypi to omit generated _SITE assignments so newly generated
PyPI packages can use the resolver.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Changes v1 -> v2:
- Follow the usual target/host _SITE fallback pattern.
- Drop the /dev/null awk input and guard missing hash files explicitly.
- Error out when no matching blake2b-256 entry is found.
---
docs/manual/adding-packages-python.adoc | 5 +++++
package/pkg-python.mk | 14 ++++++++++++++
utils/scanpypi | 9 ---------
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/docs/manual/adding-packages-python.adoc b/docs/manual/adding-packages-python.adoc
index d6bae299a0..a66af1e7e2 100644
--- a/docs/manual/adding-packages-python.adoc
+++ b/docs/manual/adding-packages-python.adoc
@@ -82,6 +82,11 @@ All the package metadata information variables that exist in the
xref:generic-package-reference[generic package infrastructure] also
exist in the Python infrastructure.
+For Python packages downloaded from PyPI, the +PYTHON_FOO_SITE+ variable
+can be omitted when the package +.hash+ file contains a +blake2b-256+
+hash for the source archive. Buildroot derives the hash-based
+files.pythonhosted.org URL from that hash.
+
Note that:
* It is not necessary to add +python+ or +host-python+ in the
diff --git a/package/pkg-python.mk b/package/pkg-python.mk
index 32ace4aac1..a301b0501c 100644
--- a/package/pkg-python.mk
+++ b/package/pkg-python.mk
@@ -454,6 +454,20 @@ endif
endif # host / target
+ifndef $(2)_SITE
+ ifdef $(3)_SITE
+ $(2)_SITE = $$($(3)_SITE)
+ else
+ $(2)_SITE = $$(strip $$(if $$(strip $$($(2)_HASH_FILES)),\
+ $$(or $$(shell \
+ awk -v filename="$$(notdir $$($(2)_SOURCE))" \
+ '$$$$1 == "blake2b-256" && $$$$3 == filename { h = $$$$2; printf "https://files.pythonhosted.org/packages/%s/%s/%s", substr(h, 1, 2), substr(h, 3, 2), substr(h, 5); exit }' \
+ $$($(2)_HASH_FILES)),\
+ $$(error $(2)_SITE must be set or $$($(2)_HASH_FILES) must contain a blake2b-256 hash for $$($(2)_SOURCE))),\
+ $$(error $(2)_SITE must be set or a hash file must exist to derive the PyPI site)))
+ endif
+endif
+
# Call the generic package infrastructure to generate the necessary
# make targets
$(call inner-generic-package,$(1),$(2),$(3),$(4))
diff --git a/utils/scanpypi b/utils/scanpypi
index de658328fe..63b8f8f4d0 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -495,15 +495,6 @@ class BuildrootPackage():
filename=targz)
lines.append(targz_line)
- if self.filename not in self.url:
- # Sometimes the filename is in the url, sometimes it's not
- site_url = self.url
- else:
- site_url = self.url[:self.url.find(self.filename)]
- site_line = '{name}_SITE = {url}'.format(name=self.mk_name,
- url=site_url)
- site_line = site_line.rstrip('/') + '\n'
- lines.append(site_line)
return lines
def __create_mk_setup(self):
--
2.53.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2026-06-17 17:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 17:42 [Buildroot] [PATCH v2 1/3] support/download: add blake2b-256 hash support James Hilliard
2026-06-17 17:42 ` James Hilliard [this message]
2026-06-17 17:42 ` [Buildroot] [PATCH v2 3/3] package/python-async-timeout: use hash-based PyPI site James Hilliard
2026-06-18 5:51 ` [Buildroot] [PATCH v2 1/3] support/download: add blake2b-256 hash support yann.morin
2026-06-18 14:04 ` [Buildroot] minimum system/coreutils requirements (was: support/download: add blake2b-256 hash support) Marcus Hoffmann via buildroot
2026-06-18 14:27 ` [Buildroot] minimum system/coreutils requirements Peter Korsgaard
2026-06-18 14:59 ` [Buildroot] minimum system/coreutils requirements (was: support/download: add blake2b-256 hash support) yann.morin
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=20260617174208.3968183-2-james.hilliard1@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=buildroot@buildroot.org \
--cc=ricardo.martincoski@datacom.com.br \
--cc=thomas.perale@mind.be \
--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