On 2022/08/10 15:45, Laurence Tratt wrote:
> The fix for this was easier than I expected: for some reason we aren't
> importing Soup.URI (is that a bug in upstream or one of our dependencies?
> I'm unsure). The patch below gives me a version of quodlibet which doesn't
> throw constant errors and which seems capable of fetching cover art and so
> on.

There is no Soup.URI python module at all, it's coming in via
gobject-introspection. So that diff just causes an import error, in turn
this prevents loading the relevant plugins and it falls back to a
different coverart fetcher which doesn't use libsoup at all..
(There's another instance in quodlibet/ext/covers/musicbrainz.py)

The fundamental problem is that quodlibet really wants libsoup2 for now.
The API changed in various ways between libsoup2 and libsoup3. (One big one
is that SoupURI was removed in favour of glib's GUri. As far as I can
tell the function quodlibet is calling is provided by soup_uri_encode
which was removed as part of that change).

gstreamer is supposed to detect a libsoup which is already loaded into the
address space (by using dlopen() with RTLD_NOLOAD to test this) and adapts
itself to use the appropriate libsoup API+ABI. It does this specifically
to avoid this type of conflict. Only if it can't find a copy of libsoup2
or libsoup3 already loaded does it use its own preference order (libsoup3
by default) and dlopen()s it (via g_module_open) itself.

(see gst_soup_load_library() in ext/soup/gstsouploader.c from
gstreamer1/plugins-good).

But we don't have RTLD_NOLOAD so this trick doesn't work...

I looked at trying to convert these functions used by quodlibet to the
soup3 API... Soup.URI.Encode is a simple enough function to %-encode
URLs and there are various alternatives in Python that we could use (and
indeed are already used in other parts of quodlibet) but they work
with strings rather than the data type that libsoup wants to use when
fetching URLs (SoupURI for soup2, GUri for soup3) and I (who am totally
not a Python coder at all) haven't figured out how to convert it.

I suppose if we can't do any better we could explicitly avoid installing
the relevant plugins in quodlibet. I'd prefer that to disabling
the plugins as a side-effect of adding an error to the .py files.

But I have a feeling this is not the only time we're going to see this
problem between $some_port_that_wants_soup-2 and gstreamer...


> 
> 
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/audio/quodlibet/Makefile,v
> retrieving revision 1.40
> diff -u -p -u -r1.40 Makefile
> --- Makefile  6 Aug 2022 11:08:47 -0000       1.40
> +++ Makefile  10 Aug 2022 14:43:00 -0000
> @@ -1,6 +1,7 @@
>  COMMENT=     audio player and tagger for GTK+ with regex support
>  
>  MODPY_EGG_VERSION= 4.5.0
> +REVISION=    0
>  DISTNAME=    quodlibet-${MODPY_EGG_VERSION}
>  PORTROACH=   skipv:release-${MODPY_EGG_VERSION}
>  
> Index: patches/patch-quodlibet_util_cover_http_py
> ===================================================================
> RCS file: patches/patch-quodlibet_util_cover_http_py
> diff -N patches/patch-quodlibet_util_cover_http_py
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-quodlibet_util_cover_http_py        10 Aug 2022 14:43:00 
> -0000
> @@ -0,0 +1,11 @@
> +Index: quodlibet/util/cover/http.py
> +--- quodlibet/util/cover/http.py.orig
> ++++ quodlibet/util/cover/http.py
> +@@ -106,6 +106,6 @@ class ApiCoverSourcePlugin(CoverSourcePlugin, HTTPDown
> +         people = list(filter(None, people))
> +         return people[0] if people else None
> + 
> +-
> ++import Soup.URI
> + def escape_query_value(s):
> +     return Soup.URI.encode(s, '&')
> 

Reply via email to