Subject: [bug#54412] [PATCH] python: use the posix_prefix sysconfig scheme on Debian

From: [email-masked]
Date: Thu, 18 Jan 2024 00:27:19 +0000

Hi Karl (2024.01.17_22:48:30_+0000)
> Gianfranoc, Stefano - thanks much for the patch wrt Automake and Debian
> Python posix_local vs. posix_prefix. Below is what I installed -- the
> code change is substantively the same as what you wrote; I just took the
> extra try..catch that Bogdan added.
> 
> I changed the paragraph in the manual about pythondir. If you could look
> at it, that would be great. Is it correct that the basic idea is that,
> with this change, Automake again follows --prefix (and related) + using
> site-packages instead of Debian's defaults of /usr/local and
> dist-packages? --thanks, karl.

Thanks for the review.

You're right about that being a part of this patch. I didn't put much
thought into that bit, because in the context of Debian package builds,
it's inconsequential. (Our Python package tooling will find things that
got installed into site-packages and move them into dist-packages.)

This patch does have the effect of moving the installation destination
from dist-packages to site-packages. But previously (before this patch
was needed) Debian's sysconfig module wasn't patched to know about
dist-packages. So, if we are comparing to that point in time, this is
returning automake behaviour back to what it used to be.

Improving on that gets tricky.

Installs into /usr/local should go into
/usr/local/lib/pythonX.Y/dist-packages.
This is what the posix_local scheme will provide, no matter what prefix
it is specified.

Installs into /usr/ shouldn't happen on a Debian system, outside a
Debian package build. But there, they should go into
/usr/lib/python3/dist-packages.
This is what the deb_system scheme will provide, no matter what prefix
is specified.

Using the posix_prefix scheme was a lazy way to use the prefix, and
restore the old behaviour.

We could special-case both the '/usr' and '/usr/local' prefixes and
select 'posix_local' and 'deb_system' schemes, as appropriate. The logic
would boil down to:

if default_scheme == 'posix_local':  # Debian
   if prefix == '/usr':
       scheme = 'deb_system'  # Should only happen during Debian package builds
   elif prefix != '/usr/local':
       scheme = 'posix_prefix'

How does that sound?

Stefano

-- 
Stefano Rivera
  http://tumbleweed.org.za/
  +1 415 683 3272