This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Hardcoded sysroot path, to MacOSX11.sdk, in python sysconfig
Type: Stage:
Components: macOS Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: akumar9, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2021-12-23 00:58 by akumar9, last changed 2022-04-11 14:59 by admin.

Messages (3)
msg409057 - (view) Author: Aditya Kumar (akumar9) Date: 2021-12-23 00:58
$ python3.9
Python 3.9.7 (default, Sep  3 2021, 12:37:55) 
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin

>>> import sysconfig
>>> cflags = sysconfig.get_config_var('CFLAGS')
>>> cflags
'-Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk'


Because of hardcoded 'MacOSX11.sdk', installation of python dependencies that are built from source fails when MacOSX11.sdk is not present on the system.
msg409065 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-12-23 05:40
Whether or not a macOS sysroot path is included in CFLAGS depends on how the Python build was configured and built. For instance, the macOS Python binaries provided on python.org do not include a sysroot path in CFLAGS; from the version info provided, you are using a Python from some other source. But, even if there is one there, there is code in the standard library helper function _osx_support.py to remove a sysroot from CFLAGS at runtime if the file is not present. That is used by distutils and *should* be being used by setuptools as well but it's possible that other build systems aren't using it or there might be a bug there. Can you give a reproducible test case showing a build failure including from where you got the Python 3.9.7 you are using?

https://github.com/python/cpython/blob/3.9/Lib/_osx_support.py#L331
msg409067 - (view) Author: Aditya Kumar (akumar9) Date: 2021-12-23 06:54
while installing pycryptodome, the package is built from source. Because no toolchain is found build fails with the following error. To work around this issue temporarily i created a symlink MacOSX11.1.sdk -> MacOSX.sdk but it is not possible to do this on all machines.


```
 Compiling with an SDK that doesn't seem to exist: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk
  Please check your Xcode installation
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -mmacosx-version-min=10.9 -Wno-nullability-completeness -Wno-expansion-to-defined -Wno-undef-prefix -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -fPIC -I/var/folders/z1/xsh33bjd5d75qltcvxqy1gmm0000gp/T/tmpn5yvyhzp/tools/deps/include -I/var/folders/z1/xsh33bjd5d75qltcvxqy1gmm0000gp/T/tmpn5yvyhzp/tools/deps/include/ncursesw -I/var/folders/z1/xsh33bjd5d75qltcvxqy1gmm0000gp/T/tmpn5yvyhzp/tools/deps/include/uuid -Werror=unguarded-availability-new -g0 -DLTC_NO_ASM -DHAVE_UINT128 -DHAVE_CPUID_H -Isrc/ -I/Users/foo/.cache/_bazel_root/c7ac193d3d155e3d99f7f1334482aa2d/external/py39/dist/include/python3.9 -c src/MD2.c -o build/temp.macosx-10.9-x86_64-3.9/src/MD2.o
  clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk' [-Wmissing-sysroot]
  In file included from src/MD2.c:28:
  src/pycrypto_common.h:58:10: fatal error: 'stdlib.h' file not found
  #include <stdlib.h>
           ^~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/clang'
~                                 
```
History
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90316
2021-12-23 06:54:43akumar9setmessages: + msg409067
2021-12-23 05:40:52ned.deilysetmessages: + msg409065
2021-12-23 00:58:43akumar9create