Skip to content

Different paths of sysconfig.get_config_var('srcdir') and os.path.dirname(sysconfig.get_makefile_filename()) #142795

@mixen56

Description

@mixen56

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-unsupportedstdlibStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dirtopic-sysconfigtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions