3

I am attempting to build a python application with binary modules on OS X. I want to build versions for Snow Leopard and Leopard from Lion. I have XCode 4 installed with the 10.5 and 10.6 sdks and have been attempting to build using the MACOSX_DEPLOYMENT_TARGET flag set to 10.6. I receive an error from distutils complaining that python was built with a different deployment target.

I tried building a separate python binary with the deployment target set to 10.6 and then used virtualenv to try to build from that, but virtualenv expected a lib directory under the base env directory that was not there.

I am a total newb at developing on Mac and not even sure if what I want to do is possible. Am I going to have to break down and have someone still running Snow Leopard build my distributions?

I really appreciate any assistance.

5
  • 1
    What are you using to build your binary packages? My guess is that as long as your python interp is built with i386 and x86_64, and you maybe set MACOSX_DEPLOYMENT_TARGET=10.5, the binaries should still work across them all? Commented Oct 4, 2011 at 21:56
  • 1
    Thanks for responding. If I enter "MACOSX_DEPLOYMENT_TARGET=10.6 python setup.py build" I get the error distutils.errors.DistutilsPlatformError: $MACOSX_DEPLOYMENT_TARGET mismatch: now "10.6" but "10.7" during configure. Commented Oct 4, 2011 at 22:15
  • 1
    I am assuming that during configure refers the the original configuration of the python install. Commented Oct 4, 2011 at 22:23
  • 1
    You may need to build another python from source instead of using the 2.7 interp that comes with Lion. You can build it FAT with i386 and x86_64 and use MACOSX_DEPLOYMENT_TARGET=10.5. this is kind of where virtualdev might help you out, since you can switch to it, build a python and just use it for your build environment instead of messing with your main python 2.7 interp Commented Oct 4, 2011 at 22:24
  • 1
    Ya, 10.7 refers to when python was build, which shipped with Lion. Commented Oct 4, 2011 at 22:24

2 Answers 2

1

The system Pythons shipped by Apple in OS X 10.7 are built for 10.7 only. The simplest solution is to download the most recent Python 2.7 or 3.2 64-bit/32-bit installer from python.org and use it since it is a universal binary that will run on either 10.6 or 10.7. If you are making an app bundle, you'll need to install a copy of py2app for it and any other 3rd-party packages like Distribute (aka easy_install) or pip.

Sign up to request clarification or add additional context in comments.

Comments

1

I found the solution, go into your /System/Library/Frameworks/Python.framework/Versions/2.7/lib/distutils/sysconfig.py

Goto line 408 that says "raise DistutilsPlatformError" and add a '#' to comment out that line of code... This will "unleash the python"

You are basically telling python "don't worry its not 10.7, I know" there could be some crashes as a result but I think otherwise. My very complex python applicaiton now compiles on MacOSX 10.8 with no troubles and it seems to do the job, QA still has to test it though.

2 Comments

Hacking system Python sources is really not something to be recommended.
You are correct, if there was any other solution I would go for it first

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.