From 02f8da13d233fe036df3f5b84e7371e1a2ac7afb Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 14 Jun 2023 15:58:32 -0400 Subject: [PATCH] fix: python agent: install on Debian python >= 3.10 Starting with Debian's Python 3.10, the default install scheme is 'posix_local' which is a Debian specific scheme based on 'posix_prefix' but with an added 'local' prefix. This is the default so users doing system wide manual installations of python modules end up in '/usr/local'. This interferes with our autotools based install which already defaults to '/usr/local' and expect a provided prefix to be used verbatim. Monkeypatch sysconfig to override this scheme and use 'posix_prefix' instead. Change-Id: I08fe77b6c8807515765e3ad0344aa6849e573b90 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- python-lttngust/setup.py.in | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/python-lttngust/setup.py.in b/python-lttngust/setup.py.in index 24f8d673..13c88af8 100644 --- a/python-lttngust/setup.py.in +++ b/python-lttngust/setup.py.in @@ -23,6 +23,28 @@ if sys.version_info < (3, 12): else: from setuptools import setup, Extension +# Starting with Debian's Python 3.10, the default install scheme is +# 'posix_local' which is a Debian specific scheme based on 'posix_prefix' but +# with an added 'local' prefix. This is the default so users doing system wide +# manual installations of python modules end up in '/usr/local'. This +# interferes with our autotools based install which already defaults to +# '/usr/local' and expect a provided prefix to be used verbatim. +# +# Monkeypatch sysconfig to override this scheme and use 'posix_prefix' instead. +if sys.version_info >= (3, 10): + import sysconfig + + original_get_preferred_scheme = sysconfig.get_preferred_scheme + + def our_get_preferred_scheme(key): + scheme = original_get_preferred_scheme(key) + if scheme == "posix_local": + return "posix_prefix" + else: + return scheme + + sysconfig.get_preferred_scheme = our_get_preferred_scheme + PY_PATH_WARN_MSG = """ -------------------------------------WARNING------------------------------------ The install directory used:\n ({0})\nis not included in your PYTHONPATH. -- 2.34.1