Source: blurhash-python
Version: 1.1.4-4
Severity: normal
python-mastodon Build-Depends on python3-blurhash. Currently its tests
aren't run at build time, but I added a direct build-dependency on
python3-pytest to fix that, only to find that a blurhash-related test
failed as follows:
___________________________ test_blurhash_decode ___________________________
api = <mastodon.Mastodon.Mastodon object at 0x7f7b059e5350>
def test_blurhash_decode(api):
fake_media_dict = {
'width': 320,
'height': 240,
'blurhash': '=~NdOWof1PbIPUXSvgbI$f'
}
> decoded_image = api.decode_blurhash(fake_media_dict)
tests/test_blurhash.py:13:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <mastodon.Mastodon.Mastodon object at 0x7f7b059e5350>, media_dict =
{'blurhash': '=~NdOWof1PbIPUXSvgbI$f', 'height': 240, 'width': 320}, out_size =
(16, 16)
size_per_component = True, return_linear = True
def decode_blurhash(self, media_dict, out_size=(16, 16),
size_per_component=True, return_linear=True):
"""
Basic media-dict blurhash decoding.
out_size is the desired result size in pixels, either absolute or per
blurhash
component (this is the default).
By default, this function will return the image as linear RGB, ready
for further
scaling operations. If you want to display the image directly, set
return_linear
to False.
Returns the decoded blurhash image as a three-dimensional list:
[height][width][3],
with the last dimension being RGB colours.
For further info and tips for advanced usage, refer to the
documentation for the
blurhash module: https://github.com/halcy/blurhash-python
"""
if not IMPL_HAS_BLURHASH:
raise NotImplementedError(
'To use the blurhash functions, please install the blurhash
Python module.')
# Figure out what size to decode to
> decode_components_x, decode_components_y =
blurhash.components(media_dict["blurhash"])
E AttributeError: module 'blurhash' has no attribute 'components'
mastodon/utility.py:104: AttributeError
I then investigated the blurhash-python source package. In the process,
I found that:
* Both https://pypi.org/project/blurhash/ (=
https://github.com/halcy/blurhash-python) and
https://pypi.org/project/blurhash-python/ exist, and are entirely
different packages
* The Debian package incorrectly claims to be related to
https://github.com/halcy/blurhash-python (in debian/control Homepage
and debian/upstream/metadata) and of the "blurhash" package on PyPI
(in debian/watch)
* The Debian package claims to be at upstream version 1.1.4, which is
the current version of the "blurhash" package on PyPI but is not a
version that has ever been released of the "blurhash-python" package
on PyPI (which went from 1.1.3 to 1.2.0)
* Debian's "blurhash-python_1.1.4.orig.tar.gz" is in fact identical to
blurhash-python 1.1.3 from PyPI, i.e.
https://files.pythonhosted.org/packages/d3/3d/311668b9bad012d83f48c2f41e31cacd97730df2155d1f92a2834fca0f9c/blurhash-python-1.1.3.tar.gz
Given that the only reverse-dependency (actually a reverse-recommends)
on python3-blurhash in Debian is python3-mastodon, and that's
demonstrably incompatible with the version that's actually packaged, I'm
inclined to suggest that the best fix might be to change the package to
match its claimed upstream metadata rather than the other way round: in
other words, replace the current blurhash-python package contents with
blurhash 1.1.4 from PyPI, versioning it as
1.1.4+ds-1 or similar. (Keeping the current source package name doesn't
seem too unreasonable, since it matches upstream's GitHub repository
name even if it doesn't match the PyPI package name.)
But I don't know if this was originally packaged for the benefit of
python-mastodon, or for some other reason. CCing Edward in case he
remembers.
Thanks,
--
Colin Watson (he/him) [[email protected]]