waf and building python modules for multiple python versions

Michael Tokarev mjt at tls.msk.ru
Sat Apr 9 07:14:30 UTC 2022


Hi!

How it is possible to build python modules for the libraries
shiped by samba (such as talloc, tdb etc) for multiple python
versions? (*)

I'm not a python expert so the following might be inaccurate,
especially the usage of words.

When you ship a python module using any standard declarative
file for python, such as setup.py. From this file, automatic
tools do exist to produce and install a python module for any
given installed python version. In debian, we have helper
tools that automatically build things for whatever python
versions being installed on the system (pybuild).

Here with waf, I don't see how it is possible. Well, I do
see one possibility: to copy source into yet another separate
subdir (as many subdirs as there are additional python
versions for the build) and run configure & build & install
in every of them in turn, specifying the right PYTHON= in
the environment.  This *should* work.

(another question is how to install just the given target
instead of installing the whole thing, again, into its own
subdir, and picking just the python modules from there).

But this is insanely ugly and requires a lot of extra
recompilation of everything on each build.

Is there a better approach?  How about I build for "default"
python first, and re-build it with PYTHON=otherpython?

(*)
Building for multiple python versions helps transitions
from one version to another. When you plan such transition,
say, from 3.9 to 3.10, you may compile many packages in
a way so they provide *two* python versions in a single
package, and when you switch python, you don't have to
rebuild everything python-related, most stuff is already
ready. And before the next transition, many updated
packages, again, will have support for both python
versions - 3.10 and the next planning 3.11.

Thanks,

/mjt



More information about the samba-technical mailing list