🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.maint.python
Article #61

Re: Interrogate PyBuild for build directory of *only* the current Python interpreter version

#61
From: Stuart Prescott
Date: Fri, 06 Nov 2026 02:50
76 lines
8029 bytes
Hi Ben

> How can I query PyBuild for the Debian packaging build directory of
> *only* the current Python interpreter version?

The trick here is to be careful what you mean by "current".

To answer your last question first, I think your mental model of what is 
going on here is likely back to front. (Using codesearch.d.n to spot 
that this is towncrier so that I can better understand your context..)

dh_auto_build runs pybuild once; pybuild then loops over the set of 
supported interpreters. Outside of the loops being run by pybuild there 
is no "current" interpreter; that means that at the time you are running 
$(MAKE) there, there is no such thing as the current interpreter. At 
that point, there are concepts of "supported" and "default" but not 
"current". Throughout the pybuild manual 'current' is used for 
replaceable parameters that are to be expanded with the 'current' value 
during any loops being run by pybuild.

If you wanted to loop over all supported interpreters (i.e. py3versions 
-s) then you'd set up a command in a PYBUILD_* variable and the literal 
{build_dir} would be expanded by pybuild when it executed the loop; 
something like PYBUILD_AFTER_BUILD could be used.

That sequence of dh_* running pybuild and then pybuild running the loop 
over all supported interpreters occurs multiple times through the 
package build.

However, we don't normally want to rebuild the documentation for each 
supported version of the interpreter - we'd only ship one version of the 
docs. We normally only build the documentation against the default 
interpreter (i.e. py3versions -d).


> That ‘pybuild_computed_build_dir’ is set earlier with this assignment:
> 
> =====
> pybuild_computed_build_dir = $(shell \
> 	pybuild --print build_dir \
> 		| cut -d ':' -f 2 \
> 		| sed -e 's/^[[:space:]]*//' \
> 	)

It's possible to do a dance with `py3versions -d` to extract the 
variable for just the default interpreter, e.g.

     pybuild --print build_dir -p $(py3versions -dv) | awk '{print $3}'

(with an extra $ in the awk command in the makefile, of course).

But even easier, all of the pipeline can be replaced with

     pybuild --print build_dir --interpreter python3

The execution of sphinx is most often run as a 
`execute_after_dh_auto_build` step. (I'd also not do that dh_link dance 
until I was installing things from the staging output into the packages, 
but that's a matter of taste.)


Related - I've wondered if the invocation of sphinx is slowly becoming 
standardised enough that we could start configuring and running it 
through some set of PYBUILD_SPHINX_* environment variables. I feel we 
collectively spend spend more time trying to figure out how to get the 
docs to build than we do the rest of the package (and I wish there was a 
PEP-standardised interface to building docs and running tests).

cheers
Stuart


-- 
Stuart Prescott   http://www.nanonanonano.net/ stuart@nanonanonano.net
Debian Developer  http://www.debian.org/       stuart@debian.org
GPG fingerprint   90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7
Technical Details
Message-ID: <NWibD-a6mp-1@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomod
References: <NWg09-a5eH-3@gated-at.bofh.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomod
From: Stuart Prescott <stuart@debian.org>
Newsgroups: linux.debian.maint.python
Subject: Re: Interrogate PyBuild for build directory of *only* the current  Python interpreter version
Date: Fri, 06 Nov 2026 03:50:01 +0100
Message-ID: <NWibD-a6mp-1@gated-at.bofh.it>
References: <NWg09-a5eH-3@gated-at.bofh.it>
X-Original-To: Ben Finney <bignose@debian.org>, debian-python@lists.debian.org
X-Mailbox-Line: From debian-python-request@lists.debian.org  Fri Nov  6 02:48:24 2026
Old-Return-Path: <stuart@debian.org>
X-Amavis-Spam-Status: No, score=-4.401 tagged_above=-10000 required=5.3
 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3] autolearn=ham autolearn_force=no
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
Autocrypt: addr=stu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n
 lkvj/Bm878lui1xJiQ6+fRLxgJZDrCwTA1ZVjJ3upFmCsZnzVgLwwLxAyaYVgeFwc2oc+qZC
 Xc2CNDSwD5scDX1enbgtkMkn/3P8jKyA9JHGVo/dMwCSgmI5DrkAEQEAAcLBXwQYAQgACQUC
 UHdJzAIbDAAKCRC7wX67E5by9ycmD/9RCWFdHUxTIPtIbClBsTNrCf8kRaUQAHK944hXfzMe
 8m9Ncd2ttiAP2PcOZxH/KjPGDyL98tIwM+8c1UI0+oHZqvsVMEbRM0f5qS9hVPNh5+o/SeFT
 lrwlC7k7w9NDycDw1AlBneQF+QSQaglMJQe/LKrxUihYmDWCmSSjkCItlxmhmRfN87DQkfuO
 oCqtam+uWiqy+aKNN8bJ/kP5gO71JFeOqoXM52HmSJAEuJ4tb3P0sgNc7tJZrm2eZ3qpbT4P
 jwbNVyN+Cq2fqsEXt4Cl0P9P5Feef0EWV4vJNvGeW59UEcBRHOy6HFQEg+5GOWUYbHJ2XAvX
 SCRgiRkucKXq0w8OZgJLAXkktmEoj4adAxrDdUfjd8HG8Ac1de0tzG957fZg0v59Z/O6O+6o
 o8m3Iweb7vzDaEOTPDqMK++GuRRC2RurKGEHkX9sWNvBadOHALoUP2XJTkRQ2lBgXu0yvEEJ
 QpeuO3/pTdt86SGVGQ/fCcbmdk9ZgC0GixtTP/lbhBtdj+62ym2VdcOGAQESuNPoFtbNLHTP
 4Ohh8Q4vj3oz8pSSr2Dx5wqh5uvLxH6F7Dn4WI9+H7s7blqwZsrWBYrz5NQLAteeDqyeCkX/
 rNAdrJokPzdpa8SzpmOz7lqGR0U5FBdjobMd+e2twXWY2+VdWPRCcVH/IrLNenvS9w==
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Debian-User: stuart
X-Mailing-List: <debian-python@lists.debian.org> archive/latest/24181
List-ID: <debian-python.lists.debian.org>
List-URL: <https://lists.debian.org/debian-python/>
List-Archive: https://lists.debian.org/msgid-search/75e9d39b-a45b-46f0-a33b-c3ac9c9f910f@debian.org
Approved: robomod@news.nic.it
Lines: 76
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Fri, 6 Nov 2026 13:48:01 +1100
X-Original-Message-ID: <75e9d39b-a45b-46f0-a33b-c3ac9c9f910f@debian.org>
X-Original-References: <87se1eq0hm.fsf@benfinney.id.au>