Package: dh-make
Version: 2.202102
Followup-For: Bug #996245

Hi Craig, Commit 4ad43078 applied a patch for Bug#996245 to make the
sample debian/rules for python packages suggest using
override_dh_auto_build-indep instead of override_dh_auto_build to
build docs only for arch-independent builds.

It's been brought to my attention that override_dh_auto_build-indep is
not the best solution for this problem.

There are two problems with it. Firstly, the suggested solution runs
dh_auto_build (without a -i flag), which means that for a full build,
the python build launched by dh_auto_build will be run twice, once for
arch-dependent and again for arch-indepedent.  The docs don't need
that, it's just using up CPU time.

Secondly, building the python package twice like that can trigger other
problems, especially with multiple python versions (we currently have
both python3.9 and python3.10), with pybuild errors like
  build: plugin pep517 failed with: File already exists
This is how we noticed the problem, when we were reviewing the build
of pymatgen with the new dh-python plugin pybuild-plugin-pyproject
(for PEP517 builds with no setup.py).

Not sure if the patched override would work better by using
"dh_auto_build -i" instead of just "dh_auto_build".  But debhelper has
a better method.

dh has a "new" (v12.8) mechanism that complements the override targets,
injecting commands before or after a step.

For the python doc build for Bug#996245, we want to call it after
dh_auto_build (in arch-independent builds), so that's
execute_after_dh_auto_build-indep. The rule for debian/rules
(in dh_make.py) could be: 

# And uncomment the following lines
#execute_after_dh_auto_build-indep: export http_proxy=127.0.0.1:9
#execute_after_dh_auto_build-indep: export https_proxy=127.0.0.1:9
#execute_after_dh_auto_build-indep:
#\tPYTHONPATH=. python3 -m sphinx -N -bhtml \\
#\tdocs/ build/html # HTML generator
#\tPYTHONPATH=. python3 -m sphinx -N -bman \\
#\tdocs/ build/man # Manpage generator'''



I suspect there's a separate problem with the http_proxy.
Even though there are both http and https variants, the transport
method doesn't seem to get processed successfully. I think it might
need http_proxy=http://127.0.0.1:9 and https_proxy=https://127.0.0.1:9
I haven't investigated this thoroughly but I'm raising it for your
attention while looking at this part of the dh-make code (not sure if
it's a sphinx bug that has since been fixed in sphinx. Certainly given
the http_ and https_ prefixes, it shouldn't be necessary to write them
explicitly a second time)


Using PYTHONPATH=. for the docs build can make problems if the package
builds python extensions (providing a .so library alongside the python
code). In that case function documentation from the extension won't be
collected by sphinx.  An alternative could be
  PYTHONPATH=$(shell pybuild --pyver `py3versions --default -v` --print 
build_dir | awk '{print $$3}' )
But that assumes pybuild is being used to build the python module.
Perhaps it's better to keep dh-make simple and not make that
assumption.


Drew

Reply via email to