[Python-modules-team] Bug#915856: sphinx: Failed cross building with Build-Depends on python3-sphinx

Dmitry Shachnev mitya57 at debian.org
Sat Jan 19 21:45:36 GMT 2019

Hi Kaliko!

Sorry that it took so long for me to reply. I was putting most of my Sphinx
time into preparing the Sphinx 1.8 transition for sid.

On Fri, Dec 07, 2018 at 11:42:09AM +0100, kaliko wrote:
> here is a follow up of a discussion started on irc:debian-devel with
> mitya57.
> I'm trying to cross build an "Architecture: any" package [0]
> (commit:52326679) using the following:
>     sudo pbuilder create --host-arch armhf
>     sudo pbuilder build --host-arch armhf ncmpc_0.33-1.dsc
> building failed on:
> "builddeps:/build/ncmpc_0.33-1.dsc:armhf : Depends: python3-sphinx:armhf but
> it is not installable"

In other packages this is usually being fixed by splitting the documentation
into a separate package that is Architecture: all.

Then Sphinx is not needed when cross-building at all — there is no sense in
cross-building Architecture: all packages, you can just build them natively.

To skip installing Sphinx on cross builds, you need to:

1) Move python3-sphinx build-dependency to Build-Depends-Indep.

2) After doing that, you can no longer use dh --with sphinxdoc, as dh will
not find sphinxdoc.pm. So you will need something like this instead:

        dh_installdocs -i -A AUTHORS

3) Also maybe you will need to pass --binary-indep to pbuilder, as it does
not automatically add that option for cross builds.

This was a solution that does not need changing or using Sphinx at all.
Now let’s talk about Sphinx. There is bug #818115 which discusses how to
make it possible to install Sphinx in cross-build environments.

Last discussion on that bug was in 2016, so I checked whether some
things described there are still actual. Found this thing:

> So maybe we can say that architectures don't matter for sphinx by
> marking it Multi-Arch: foreign? Unfortunately, no. python-sphinx
> transitively depends on python-markupsafe (via python-jinja2) and thus
> exposes it. Since python-markupsafe is an architecture dependent Python
> extension, python-sphinx exposes the architecture. This is the gist of
> the multiarch interpreter problem.

I looked at markupsafe code, and found out that the architecture-specific
part of it is optional:


So even if it is installed for a wrong architecture, it would still be

Maybe this means that python3-sphinx can be marked Multi-Arch: foreign.

However, I am not sure this is a safe thing to do. One potential issue may be
that Sphinx autodoc extension [1] imports arbitrary Python code, and that
code may be a compiled (for the host architecture) extension that will fail to
import with the build architecture interpreter.

Also, I wonder if just making src:sphinx binary packages Multi-Arch: foreign
will be enough, or we should also mark all its dependencies Multi-Arch:
foreign too.

I am Cc’ing Helmut Grohne who filed #818115 and who is a cross-building
expert. Dear Helmut, can you give me your opinion on this? Is my analysis

[1]: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html

Dmitry Shachnev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/python-modules-team/attachments/20190120/86a00518/attachment.sig>

More information about the Python-modules-team mailing list