python-build-standalone
python-build-standalone copied to clipboard
`-isysroot` flag in macOS distributions prevent compiling some dependencies (well pybullet at least)
I downloaded the distribution for cpython-3.12.5+20240814-aarch64-apple-darwin-install_only.tar.gz and ran the following:
❯ ./python/bin/python -c "import sysconfig; print(sysconfig.get_config_vars('CFLAGS'))"
['-fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -arch arm64 -mmacosx-version-min=11.0 -Wno-nullability-completeness -Wno-expansion-to-defined -Wno-undef-prefix -isysroot /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -fPIC -Werror=unguarded-availability-new']
I was trying to install pybullet and it needs to compile a wheel for it, and I was getting the following error (short version included)
Compiling with an SDK that doesn't seem to exist: /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
I don't have this version of Xcode on my machine. I think that the inclusion of -isysroot /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk in the standalone version prevents me from compiling Pybullet with this Python version.
I found that this flag gets added here: https://github.com/indygreg/python-build-standalone/blob/953883ae97ffdebed64a324cc5b910c3daea8d94/cpython-unix/build.py#L188-L189
When I build and install Python on my machine, I get this:
❯ python -c "import sysconfig; print(sysconfig.get_config_var('CFLAGS'))"
-fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/bzip2/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/bzip2/include
I was able to install pybullet on my machine using the Python I compiled.
I'm not sure if it also affects compiling of other dependencies, I only really found this with pybullet but happy to try out installing any others if you think they might be useful?
Also, sorry if it's a bit jumbled, didn't want to write a long essay with loads of detail if you didn't need it 😅