python-build-standalone icon indicating copy to clipboard operation
python-build-standalone copied to clipboard

[darwin] pre-built artifacts reference SDK path from the build host

Open f355 opened this issue 3 years ago • 3 comments

In darwin artifacts downloaded from the release page, the file lib/python3.10/_sysconfigdata__darwin_darwin.py contains the following flag:

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk

If the machine has only Command Line Tools installed, then trying to install any pip package that has C code in it fails with the following error:

  running build_ext
  creating build/temp.macosx-11.0-arm64-3.10
  creating build/temp.macosx-11.0-arm64-3.10/src
  Compiling with an SDK that doesn't seem to exist: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk
  Please check your Xcode installation

...

  clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' [-Wmissing-sysroot]
  In file included from src/MD2.c:28:
  src/common.h:34:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for pycryptodomex

The situation gets worse with upgrading XCode to 14.1 as it no longer includes MacOSX12.3.sdk, at least in the Release Candidate 2.

f355 avatar Oct 25 '22 13:10 f355

I was able to work around this by running ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk, but that makes me feel dirty.

f355 avatar Oct 25 '22 13:10 f355

It is a known problem that build-time paths leak into the distribution.

See https://gregoryszorc.com/docs/python-build-standalone/main/quirks.html#references-to-build-time-paths.

I wish I had a better solution for you, but I don't at this time. This is a complex problem with no easy solutions. The best I can recommend is for you to manually patch the bad _sysconfigdata_*.py file post extraction. This is something I hope we can make turnkey one day.

indygreg avatar Nov 09 '22 03:11 indygreg

oh well. thank you anyway!

f355 avatar Nov 09 '22 08:11 f355