setting pyobjc sdk version

Issue #121 resolved
Justin Nesselrotte
created an issue

I'm running version 10.9, but I want to target 10.6 for a packaged app. Do I have to build python against 10.6 as well? Right now I can't figure out how to get pyobjc to build against 10.6.

Comments (17)

  1. Kentzo

    Both sdk and deployment target can be set via --sdk-root and --deployment-target like this: python setup.py build_ext --sdk-root=… --deployment-target=… install

    However it's not possible to do that if you install it via pip's requirements.

  2. Ronald Oussoren repo owner

    Oops, forgot to add a message:

    The best way to target older OSX releases is to build Python with the right deployment target (and when targetting 10.6 you can also use the installer on Python.org).

    PyObjC itself can safely be build using the latest SDK and will automatically use the same deployment target as Python itself.

    I'm -1 on reading settings from the environment, it is way to easy to accidentally influence the build without noticing this.

    BTW. I have plans to create a CI setup that will build and test wheels for PyObjC on a number of OSX versions. Not sure when I'll actually get around to doing that though, I have had those plans for a long time and haven't found the time yet to implement this (and then find the hardware to let this run in the background)

    Closing this issue because this isn't a bug.

  3. Kentzo

    @Ronald Oussoren I'm building on OSX 10.8 with latest xcode installed (which embeds 10.8 and 10.9 sdk) and I build my own Python. Python's ./configure does not accept any options to specify SDK, so I'm specifying it via env variables:

    • MACOSX_DEPLOYMENT_TARGET
    • SDKROOT
    • CFLAGS (-mmacosx-version-min=, -isysroot)
    • LDFLAGS (-mmacosx-version-min=)

    It appears that python is build against 10.8

    However when I install pyobjc-core via pip, it still uses 10.9 (I see paths in the build log).

    And I cannot use build_ext, because it cannot be set per requirement for now.

  4. Ronald Oussoren repo owner

    Python does accepts and argument to --with-universalsdk to specify the SDK.

    AFAIK the changes to CFLAGS and LDFLAGS aren't necessary, the MACOSX_DEPLOYMENT_TARGET variable should be sufficient.

  5. Ronald Oussoren repo owner

    The name of the option is an historical artifact, it was introduced when adding support for fat binaries (during the introduction of Intel Macs way back when). It might be better to redesign that part of the configure interface, but on the other hand backward compatibility is also very useful here (and hacking on autoconf scripts sucks big time)

    Ronald

  6. Ronald Oussoren repo owner

    There’s also —with-universal-archs that can select the architectures to build. IIRC you can use that to select a single architecture (and I know, that’s layers upon layers of cruft…)

  7. Kentzo

    I tried

    --enable-universalsdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk --with-universal-archs=64-bit
    

    but it ended up with this options in invocations of compiler:

    -arch ppc64 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
    

    Aslo, as you can see it ended up specifying sysroot twice i.e. it used my CFLAGS. I wonder why pip picks up 10.9…

  8. Kentzo

    From python's configure:

            case "$UNIVERSAL_ARCHS" in
            32-bit)
               UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
               LIPO_32BIT_FLAGS=""
               ARCH_RUN_32BIT=""
               ;;
            64-bit)
               UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
               LIPO_32BIT_FLAGS=""
               ARCH_RUN_32BIT="true"
               ;;
            all)
               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
               LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
               ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
               ;;
            intel)
               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
               LIPO_32BIT_FLAGS="-extract i386"
               ARCH_RUN_32BIT="/usr/bin/arch -i386"
               ;;
            intel-32)
               UNIVERSAL_ARCH_FLAGS="-arch i386"
               LIPO_32BIT_FLAGS=""
               ARCH_RUN_32BIT=""
               ;;
            3-way)
               UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
               LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
               ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
               ;;
            *)
               as_fn_error $? "proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way" "$LINENO" 5
               ;;
            esac
    
  9. Kentzo

    That's how I configure it now:

    VERBOSE=1 \
    CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc CXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ \
    "CFLAGS=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.8 -mssse3 -gdwarf-4 -gstrict-dwarf -fslp-vectorize -fvectorize" \
    "LDFLAGS=-L/Users/developer/andy/app/build/usr/lib -mmacosx-version-min=10.8 -Xlinker -dead_strip -Xlinker -export_dynamic" \
    MACOSX_DEPLOYMENT_TARGET=10.8 \
    SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk \
    

    That's how it compiles:

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
    -c \
    -Wno-unused-result \
    -DNDEBUG \
    -g \
    -fwrapv \
    -O3 \
    -Wall \
    -Wstrict-prototypes \
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk \
    -mmacosx-version-min=10.8 \
    -mssse3 \
    -gdwarf-4 \
    -gstrict-dwarf \
    -fslp-vectorize \
    -fvectorize \
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk \
    -mmacosx-version-min=10.8 \
    -mssse3 \
    -gdwarf-4 \
    -gstrict-dwarf \
    -fslp-vectorize \
    -fvectorize \
    -Werror=declaration-after-statement \
    -I. \
    -IInclude \
    -I/.../src/Python/Include \
    -DPy_BUILD_CORE \
    -o Modules/python.o /.../src/Python/Modules/python.c
    
  10. Kentzo

    And that's how pip compiles pyobjc-core:

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
    -DNDEBUG \
    -g \
    -fwrapv \
    -O3 \
    -Wall \
    -Wstrict-prototypes \
    -I/.../usr/include \
    -mmacosx-version-min=10.8 \
    -mssse3 \
    -gdwarf-4 \
    -gstrict-dwarf \
    -fslp-vectorize \
    -fvectorize \
    -I/.../usr/include \
    -I/.../usr/include/python3.4m \
    -c Modules/objc/test/voidpointer.m -o build/temp.macosx-10.8-x86_64-3.4/Modules/objc/test/voidpointer.o \
    -DPyObjC_STRICT_DEBUGGING \
    -DMACOSX \
    -DPyObjC_BUILD_RELEASE=1008 \
    -DMACOSX \
    -g \
    -fexceptions \
    -Wall \
    -Wstrict-prototypes \
    -Wmissing-prototypes \
    -Wformat=2 \
    -W \
    -Wpointer-arith \
    -Wmissing-declarations \
    -Wnested-externs \
    -W \
    -Wno-import \
    -Wno-unknown-pragmas \
    -Wshorten-64-to-32 \
    -IModules/objc \
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
    
  11. Log in to comment