Bug#1026312: meson: diff for NMU version 1.0.0-1.1

2022-12-27 Thread Stefano Rivera
Hi Eli (2022.12.24_21:46:13_-0400)
> This patch is non-upstreamable.

For context, this patch is along the same lines as changes you are
making in your refactor, upstream in
https://github.com/mesonbuild/meson/pull/11133

Your refactor goes further and removes distutils use entirely, where
possible. It's still required on older Debian systems, because the
deb_system scheme was patched into distutils but not sysconfig at the
time.

So, I still think we should be landing this patch in Debian, until your
refactor is released, and I haven't cancelled the NMU.

> I must confess however that I am surprised that setuptools is installed
> in your buildd at all -- Meson doesn't use it, and projects using Meson
> most likely don't also need setuptools at the same time. So this should
> be a moot point.
> 
> If setuptools is not installed, it cannot overwrite the stdlib
> distutils. And there's a viable approach to not using distutils by the
> time distutils is removed from the stdlib.

To expand on what Eli is saying here, if meson Conflicted with
python3-setuptools, or exported SETUPTOOLS_USE_DISTUTILS=stdlib, then
this patch would not be required.

However, such a conflict wouldn't be ideal for user systems. And
virtualenvs still come with setuptools by default, so meson probably
needs to be able to coexist with it.

For the export option, I wouldn't want to patch something like that into
our meson, unless we had to. That should be an upstream decision.

I think coexisting with setuptools and setuptools-distutils is the best
way forward.

SR

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



Bug#1026312: meson: diff for NMU version 1.0.0-1.1

2022-12-24 Thread Eli Schwartz
This patch is non-upstreamable.

I must confess however that I am surprised that setuptools is installed
in your buildd at all -- Meson doesn't use it, and projects using Meson
most likely don't also need setuptools at the same time. So this should
be a moot point.

If setuptools is not installed, it cannot overwrite the stdlib
distutils. And there's a viable approach to not using distutils by the
time distutils is removed from the stdlib.

-- 
Eli Schwartz



Bug#1026312: meson: diff for NMU version 1.0.0-1.1

2022-12-24 Thread Stefano Rivera
Control: tags 1026312 + patch
Control: tags 1026312 + pending

Dear maintainer,

I've prepared an NMU for meson (versioned as 1.0.0-1.1) and
uploaded it to DELAYED/5. Please feel free to tell me if I
should delay it longer.

Regards.

SR
diff -Nru meson-1.0.0/debian/changelog meson-1.0.0/debian/changelog
--- meson-1.0.0/debian/changelog	2022-12-23 12:24:54.0 -0400
+++ meson-1.0.0/debian/changelog	2022-12-24 11:22:03.0 -0400
@@ -1,3 +1,11 @@
+meson (1.0.0-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Patch: Correctly select the Debian python scheme with modern distutils.
+Closes: #1026312.
+
+ -- Stefano Rivera   Sat, 24 Dec 2022 11:22:03 -0400
+
 meson (1.0.0-1) unstable; urgency=medium
 
   * New upstream release.
diff -Nru meson-1.0.0/debian/patches/3-debian-sysconfig-layout.patch meson-1.0.0/debian/patches/3-debian-sysconfig-layout.patch
--- meson-1.0.0/debian/patches/3-debian-sysconfig-layout.patch	1969-12-31 20:00:00.0 -0400
+++ meson-1.0.0/debian/patches/3-debian-sysconfig-layout.patch	2022-12-24 11:22:03.0 -0400
@@ -0,0 +1,60 @@
+From 9cea9e351d20d58f447b06baa7bb9a3f5cc40ea4 Mon Sep 17 00:00:00 2001
+From: Stefano Rivera 
+Date: Mon, 19 Dec 2022 19:56:32 -0400
+Subject: [PATCH] Update the Debian Python path detection for setuptools >= 60
+
+Debian now (since Python 3.10.2-6) adds the deb_system scheme to
+sysconfig. Newer distutils (such as bundled with setuptools >= 60) adds
+fetch schemes from sysconfig, rather than duplicating the sysconfig
+schemes statically in distutils.command.install.
+
+This change broke meson's deb_system check.
+
+This patch replaces that mechanism (for newer Debian releases) with
+explicit scheme selection, which is far simpler.
+But it also retains the old mechanism, for older Debian releases that
+require it (Debian <= 11).
+
+Fixes: #8739 (for python module, and makes similar minimal changes to the python3 module)
+
+Fixes: https://bugs.debian.org/1026312
+
+Forwarded: https://github.com/mesonbuild/meson/pull/11211
+---
+ mesonbuild/modules/python.py | 14 +++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/mesonbuild/modules/python.py b/mesonbuild/modules/python.py
+index f74d10e4c..68632af2d 100644
+--- a/mesonbuild/modules/python.py
 b/mesonbuild/modules/python.py
+@@ -363,15 +363,23 @@ def get_distutils_paths(scheme=None, prefix=None):
+ # default scheme to a custom one pointing to /usr/local and replacing
+ # site-packages with dist-packages.
+ # See https://github.com/mesonbuild/meson/issues/8739.
+-# XXX: We should be using sysconfig, but Debian only patches distutils.
++# Until version 3.10.2-6, Debian only patched distutils, not sysconfig.
+ 
+ if 'deb_system' in distutils.command.install.INSTALL_SCHEMES:
++# Debian systems before setuptools-bundled distutils was used by default
+ paths = get_distutils_paths(scheme='deb_system')
+ install_paths = get_distutils_paths(scheme='deb_system', prefix='')
+ else:
+-paths = sysconfig.get_paths()
++if 'deb_system' in sysconfig.get_scheme_names():
++# Use Debian's custom deb_system scheme (with our prefix)
++scheme = 'deb_system'
++elif sys.version_info >= (3, 10):
++scheme = sysconfig.get_default_scheme()
++else:
++scheme = sysconfig._get_default_scheme()
++paths = sysconfig.get_paths(scheme=scheme)
+ empty_vars = {'base': '', 'platbase': '', 'installed_base': ''}
+-install_paths = sysconfig.get_paths(vars=empty_vars)
++install_paths = sysconfig.get_paths(vars=empty_vars, scheme=scheme)
+ 
+ def links_against_libpython():
+ from distutils.core import Distribution, Extension
+-- 
+2.35.1
+
diff -Nru meson-1.0.0/debian/patches/series meson-1.0.0/debian/patches/series
--- meson-1.0.0/debian/patches/series	2021-02-14 08:58:40.0 -0400
+++ meson-1.0.0/debian/patches/series	2022-12-24 11:22:03.0 -0400
@@ -1,2 +1,3 @@
 1-disable-openmpi.patch
 2-disable-rootdir-test.patch
+3-debian-sysconfig-layout.patch