Different paths of sysconfig.get_config_var('srcdir') and os.path.dirname(sysconfig.get_makefile_filename())
Bug report
Bug description:
Test test_distutils fails at test_srcdir subtest on OS Elbrus due to config var srcdir is real path, but makefile path is not real path.
======================================================================
FAIL: test_srcdir (distutils.tests.test_sysconfig.SysconfigTestCase.test_srcdir)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.11/distutils/tests/test_sysconfig.py", line 71, in test_srcdir
self.assertEqual(
AssertionError: '/usr/lib/python3.11/config-3.11-e2k-linux-gnu' != '/usr/lib64/python3.11/config-3.11-e2k-linux-gnu'
- /usr/lib/python3.11/config-3.11-e2k-linux-gnu
+ /usr/lib64/python3.11/config-3.11-e2k-linux-gnu
? ++
To prevent fail it is possible use the patch for the main branch:
diff --git a/Lib/sysconfig/__init__.py b/Lib/sysconfig/__init__.py
index 8ff9c99..ce84b0e 100644
--- a/Lib/sysconfig/__init__.py
+++ b/Lib/sysconfig/__init__.py
@@ -317,10 +317,10 @@ def get_makefile_filename():
# GH-127429: When cross-compiling, use the Makefile from the target, instead of the host Python.
if cross_base := os.environ.get('_PYTHON_PROJECT_BASE'):
- return os.path.join(cross_base, 'Makefile')
+ return _safe_realpath(os.path.join(cross_base, 'Makefile'))
if _PYTHON_BUILD:
- return os.path.join(_PROJECT_BASE, "Makefile")
+ return _safe_realpath(os.path.join(_PROJECT_BASE, "Makefile"))
if hasattr(sys, 'abiflags'):
config_dir_name = f'config-{_PY_VERSION_SHORT}{sys.abiflags}'
@@ -330,7 +330,7 @@ def get_makefile_filename():
if hasattr(sys.implementation, '_multiarch'):
config_dir_name += f'-{sys.implementation._multiarch}'
- return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile')
+ return _safe_realpath(os.path.join(get_path('stdlib'), config_dir_name, 'Makefile'))
def _import_from_directory(path, name):
# uname -a
Linux hofman 6.1.0-1.8-e8c-nn #1 SMP Tue Nov 25 12:07:16 UTC 2025 e2k E8C E8C GNU/Linux
# cat /etc/os-release
PRETTY_NAME="Elbrus Linux 9.3.6"
NAME="Elbrus Linux"
VERSION_ID="9"
VERSION="9.3.6"
ID="elbrus"
HOME_URL="http://www.mcst.ru/"
SUPPORT_URL="http://www.mcst.ru/support/"
BUG_REPORT_URL="https://bugs.mcst.ru/"
ELBRUS_SP_VERSION="1.29.14"
ELBRUS_KERNEL_VERSION="6.1.0-1.8"
ELBRUS_DATE_BUILD="05.12.2025"
# python3 --version
Python 3.11.3
Please consider contributing the patch.
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Hi, thank you for reporting this.
But please note that distutils is deprecated and was removed in Python 3.12. Therefore, Python 3.11 is the latest version that still contains it. Python 3.11 is also in maintenance mode, which only accepts security fixes. So I think this won’t be fixed.
Sorry, I re-checked the issue. Your proposed change is not in the tests for the deprecated distutils, although it is exposed there. So maybe we should fix it. I'm not entirely sure about this, so let's wait for others' thoughts.