[Buildroot] [PATCH v2] package/python-diskcache: new package
Marcus Hoffmann
buildroot at bubu1.eu
Tue Oct 21 11:31:14 UTC 2025
Hi Thomas,
thanks for the review!
On 10/21/25 12:16, Thomas Petazzoni wrote:
> Hello Marcus,
>
> On Tue, 21 Oct 2025 11:35:00 +0200
> Marcus Hoffmann <buildroot at bubu1.eu> wrote:
>
>> The package imports itself in setup.py to get the package-name and
>> version number. This doesn't work during the buildroot build, so we
>> replace this by the hardcoded package-name and the version number stored
>> in buildroot.
>>
>> Signed-off-by: Marcus Hoffmann <buildroot at bubu1.eu>
>
> Sounds good overall. One question below.
>
>
>> diff --git a/package/python-diskcache/python-diskcache.mk b/package/python-diskcache/python-diskcache.mk
>> new file mode 100644
>> index 0000000000..327d076779
>> --- /dev/null
>> +++ b/package/python-diskcache/python-diskcache.mk
>> @@ -0,0 +1,20 @@
>> +################################################################################
>> +#
>> +# python-diskcache
>> +#
>> +################################################################################
>> +
>> +PYTHON_DISKCACHE_VERSION = 5.6.3
>> +PYTHON_DISKCACHE_SOURCE = diskcache-$(PYTHON_DISKCACHE_VERSION).tar.gz
>> +PYTHON_DISKCACHE_SITE = https://files.pythonhosted.org/packages/3f/21/1c1ffc1a039ddcc459db43cc108658f32c57d271d7289a2794e401d0fdb6
>> +PYTHON_DISKCACHE_SETUP_TYPE = setuptools
>> +PYTHON_DISKCACHE_LICENSE = Apache-2.0
>
> License is OK, checked here.
>
>> +PYTHON_DISKCACHE_LICENSE_FILES = LICENSE
>> +
>> +define PYTHON_DISKCACHE_REMOVE_SELF_IMPORT
>> + sed -i -e '/import diskcache/d' -e 's/diskcache.__title__/"diskcache"/' -e 's/diskcache.__version__/"$(PYTHON_DISKCACHE_VERSION)"/' $(@D)/setup.py
>> +endef
>
> This could use some splitting:
>
> sed -i -e '/import diskcache/d' \
> -e 's/diskcache.__title__/"diskcache"/' \
> -e 's/diskcache.__version__/"$(PYTHON_DISKCACHE_VERSION)"/' \
> $(@D)/setup.py
>
> but perhaps more importantly, has this been reported upstream? How can
> this even work? You need the thing installed... before you install it?
This was, unfortunately, a very common pattern in setup.py builds but
it's going away with projects switching to declarative build definitions
via pyproject.toml. (Which diskcache hasn't done yet, but I assume will
do eventually, maintenance is a bit slow currently). setup.py is just a
python script and python allows importing modules from $CWD, even if
they are not installed. That's how that works in general.
Now I was confused why past me claimed that the same doesn't work inside
the buildroot build and the reason for that is that host-python3 doesn't
build with sqlite support, so the diskcache import (at build-time) fails.
Perhaps a less hacky, but also more wasteful, approach to solving this
is enforcing host-python sqlite support is built when diskcache is
selected. I just tested that and it works, unsure what approach to chose
now. WDYT?
>
> Thomas
Marcus
More information about the buildroot
mailing list