import sys
import os
-import sysconfig
-from distutils.core import setup, Extension
+# Distutils was removed in Python 3.12, use setuptools as an alternative.
+if sys.version_info >= (3, 12):
+ from setuptools import setup, Extension
+else:
+ from distutils.core 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
+
+else:
+ import distutils.sysconfig as sysconfig
PY_PATH_WARN_MSG = """
-------------------------------------WARNING------------------------------------
# distutils performs a similar transformation step on LDSHARED on
-# darwin to use the overriden CC as the default command for LDSHARED
+# darwin to use the overridden CC as the default command for LDSHARED
# (see distutils' customize_compiler() step in the sysconfig module).
#
# This takes it a step further by using our own LDFLAGS (when available)
-# along with the overriden compiler and ensure that flags that are unsupported
-# by either the Python interprter's CC or the overriden CC don't cause a
+# along with the overridden compiler and ensure that flags that are unsupported
+# by either the Python interprter's CC or the overridden CC don't cause a
# build failure.
def get_ldshared():
cc = os.environ.get("CC")
}
if len(args) == 0:
+ # Return a dict with all config vars.
all_config_vars = original_get_config_vars()
for name in overridden_config_vars:
all_config_vars[name] = overridden_config_vars[name]
- return all_config_vars
-
- subset_config_vars = []
- for name in args:
- if name not in overridden_config_vars:
- [var] = original_get_config_vars(name)
- subset_config_vars.append(var)
- continue
- subset_config_vars.append(overridden_config_vars[name])
+ return all_config_vars
+ else:
+ # Return a list with the requested config vars.
+ subset_config_vars = []
+ for name in args:
+ if name in overridden_config_vars:
+ subset_config_vars.append(overridden_config_vars[name])
+ else:
+ subset_config_vars.append(original_get_config_vars(name)[0])
- return subset_config_vars
+ return subset_config_vars
sysconfig.get_config_vars = our_get_config_vars
sources=["bt2/native_bt.c", "@srcdir@/bt2/logging.c"],
libraries=["babeltrace2", "glib-2.0"],
extra_objects=[
- "@top_builddir@/src/autodisc/.libs/libbabeltrace2-autodisc.a",
- "@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a",
- "@top_builddir@/src/common/.libs/libbabeltrace2-common.a",
- "@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a",
- "@top_builddir@/src/string-format/.libs/libbabeltrace2-string-format.a",
+ "@top_builddir@/src/autodisc/.libs/libautodisc.a",
+ "@top_builddir@/src/logging/.libs/liblogging.a",
+ "@top_builddir@/src/common/.libs/libcommon.a",
+ "@top_builddir@/src/py-common/.libs/libpy-common.a",
+ "@top_builddir@/src/string-format/.libs/libstring-format.a",
],
)