From 591a3cbc4920e5960d59405f8037f53b6357e80b Mon Sep 17 00:00:00 2001
From: NanoNabla <43477372+NanoNabla@users.noreply.github.com>
Date: Mon, 12 Aug 2024 10:49:21 +0200
Subject: [PATCH] Ports from distutils to setuptools

---
 scorep/subsystem.py | 5 +++--
 setup.py            | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/scorep/subsystem.py b/scorep/subsystem.py
index f832f30..e359aa6 100644
--- a/scorep/subsystem.py
+++ b/scorep/subsystem.py
@@ -88,8 +88,9 @@ def generate(scorep_config, keep_files=False):
     # setuptools, which replaces distutils, calls uname in python < 3.9 during distutils bootstraping.
     # When LD_PRELOAD is set, this leads to preloading Score-P to uname, and crashes the later tracing.
     # To avoid this, we need to do the distutils bootstrap as late as possible.
-    import distutils.ccompiler
-    cc = distutils.ccompiler.new_compiler()
+    # Setuptools does not support ccompiler.new_compiler https://github.com/pypa/setuptools/issues/4540
+    from setuptools._distutils.ccompiler import new_compiler
+    cc = new_compiler()
 
     compiled_subsystem = cc.compile(
         [temp_dir + "/scorep_init.c"], output_dir=temp_dir)
diff --git a/setup.py b/setup.py
index c938d8e..33d2a63 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
 import os
 import sys
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
 import scorep.helper
 from scorep.instrumenter import has_c_instrumenter