waf and building python modules for multiple python versions

Andrew Bartlett abartlet at samba.org
Sun Apr 10 04:26:27 UTC 2022

On Sat, 2022-04-09 at 11:13 +0300, Michael Tokarev wrote:
> I just built talloc with default python 3.10, removed
> bin/default/libpytalloc-util.cpython-310-x86-64-linux-gnu.so, and
> re-built it thysly:
>   PYTHON=python3.9 make
> and it re-linked the same libpytalloc-util.cpython-310-x86-64-linux-gnu.so.
> So apparently it recorded somewhere the python binary which was
> used during configure.

Yes, the above command will run 'waf' with python 3.9 but yes, the
configure results were already stored (just as it would have been with
autoconf) a configure time.

> > That is the only plan I can think of.  But which python version would
> > Samba's python-using libs link to?  For as long as you ship smbtorture
> > and expect it to work you would have to do multiple versions of that as
> > well...
> It is not about samba proper. These will have to be recompiled as
> a whole anyway.  This is about libraries (talloc, tdb) which are
> used by other packages. When your default python is 3.9 but 3.10
> is also available, you build, say, python3-talloc package to contain
> *two* versions of the pytalloc module (containing
> libpytalloc-util.cpython-39-x86-64-linux-gnu.so and
> libpytalloc-util.cpython-310-x86-64-linux-gnu.so ).  Other packages
> are built with whatever python version they choose, this is not
> relevant by now (either of 3.9 or 3.10).  Next, you switch default
> python from 3.9 to 3.10. If a package used 3.9 module in talloc,
> it will just switch to 3.10 one which is *already provided* by
> python3-talloc package, there's no need to rebuild python3-talloc
> so that packages using it will work after python version switch.

Just run the whole thing twice for those, right from the top, picking
out the different modules.  The 'used elsewhere' libs are much simpler
and only have python -> C deps thankfully.  They are also really fast
to recompile.

Andrew Bartlett

Andrew Bartlett (he/him)        https://samba.org/~abartlet/
Samba Team Member (since 2001)  https://samba.org
Samba Developer, Catalyst IT    https://catalyst.net.nz/services/samba

More information about the samba-technical mailing list