From a.h.jaffe at gmail.com Mon Oct 19 17:25:56 2015 From: a.h.jaffe at gmail.com (Andrew Jaffe) Date: Mon, 19 Oct 2015 16:25:56 +0100 Subject: [Pythonmac-SIG] OS X Python: can I explicitly set MACOSX_DEPLOYMENT_TARGET for extensions? Message-ID: [Also posted to general python list...] I use the python.org framework build of Python under recent versions of OS X (i.e., 10.11 El Capitan). I need to build some extensions that rely on recent versions of compilers (e.g., C++-11 features). However the python.org python is built to work on older systems as well, for backward compatibility. Hence, it has the environment variable MACOSX_DEPLOYMENT_TARGET=10.6. This means that extensions are built by default with a toolchain that, I think, mimics gcc-4.2, in particular in terms of what stdlib it searches. In the past, I have fixed this by installing more recent compilers with homebrew and explicitly setting CC, CXX, etc before installation. However, I have tried just setting MACOSX_DEPLOYMENT_TARGET=10.11, and that seems to work. Is this safe? Are there any downsides? (I don't need to distribute these builds, just use them locally?) Conversely, are there any upsides? Does a newer deployment target allow more recent compilers and/or higher optimizations? -Andrew From barry at barrys-emacs.org Tue Oct 27 04:42:01 2015 From: barry at barrys-emacs.org (Barry Scott) Date: Tue, 27 Oct 2015 08:42:01 +0000 Subject: [Pythonmac-SIG] OS X Python: can I explicitly set MACOSX_DEPLOYMENT_TARGET for extensions? In-Reply-To: References: Message-ID: <09E0A982-89BF-402D-8253-186CE29CC941@barrys-emacs.org> > On 19 Oct 2015, at 16:25, Andrew Jaffe wrote: > > [Also posted to general python list...] > > I use the python.org framework build of Python under recent versions of > OS X (i.e., 10.11 El Capitan). I need to build some extensions that rely > on recent versions of compilers (e.g., C++-11 features). However the > python.org python is built to work on older systems as well, for > backward compatibility. > > Hence, it has the environment variable MACOSX_DEPLOYMENT_TARGET=10.6. > This means that extensions are built by default with a toolchain that, I > think, mimics gcc-4.2, in particular in terms of what stdlib it searches. > > In the past, I have fixed this by installing more recent compilers with > homebrew and explicitly setting CC, CXX, etc before installation. > > However, I have tried just setting MACOSX_DEPLOYMENT_TARGET=10.11, and > that seems to work. Is this safe? Are there any downsides? (I don't need > to distribute these builds, just use them locally?) I built pysvn with MACOSX_DEPLOYMENT_TARGET being 10.9, 10.10 and 10.11 without issue. But I am not using c++11 features yet. I?m facing the problem that the SDK for 10.9 and 10.10 is missing from the latest Xcode release. It only has 10.11 SDK. I?m planning to use a VM running OS X 10.10 with the previous Xcode for public builds, which is not your problem. On windows I have seen issues with runtime API incompatibly between older and newer compiler. At least on Windows you must use the right compiler and runtime to match the python build you have. Linux is trouble free as python is built with the distribution?s chosen compiler which is the one you use to build the extension. > Conversely, are there any upsides? Does a newer deployment target allow > more recent compilers and/or higher optimizations? The upside is indeed better compiler and access to newer/fixed APIs. Barry > > -Andrew > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > https://mail.python.org/mailman/listinfo/pythonmac-sig > unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG > From ronaldoussoren at mac.com Tue Oct 27 07:34:11 2015 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Tue, 27 Oct 2015 12:34:11 +0100 Subject: [Pythonmac-SIG] OS X Python: can I explicitly set MACOSX_DEPLOYMENT_TARGET for extensions? In-Reply-To: <09E0A982-89BF-402D-8253-186CE29CC941@barrys-emacs.org> References: <09E0A982-89BF-402D-8253-186CE29CC941@barrys-emacs.org> Message-ID: <52D88A96-95C8-4406-A425-87DB8626F95A@mac.com> Op 27 okt. 2015 om 09:42 heeft Barry Scott het volgende geschreven: > >> On 19 Oct 2015, at 16:25, Andrew Jaffe wrote: >> >> [Also posted to general python list...] >> >> I use the python.org framework build of Python under recent versions of >> OS X (i.e., 10.11 El Capitan). I need to build some extensions that rely >> on recent versions of compilers (e.g., C++-11 features). However the >> python.org python is built to work on older systems as well, for >> backward compatibility. >> >> Hence, it has the environment variable MACOSX_DEPLOYMENT_TARGET=10.6. >> This means that extensions are built by default with a toolchain that, I >> think, mimics gcc-4.2, in particular in terms of what stdlib it searches. >> >> In the past, I have fixed this by installing more recent compilers with >> homebrew and explicitly setting CC, CXX, etc before installation. >> >> However, I have tried just setting MACOSX_DEPLOYMENT_TARGET=10.11, and >> that seems to work. Is this safe? Are there any downsides? (I don't need >> to distribute these builds, just use them locally?) > > I built pysvn with MACOSX_DEPLOYMENT_TARGET being 10.9, 10.10 and 10.11 > without issue. But I am not using c++11 features yet. > > I?m facing the problem that the SDK for 10.9 and 10.10 is missing from the > latest Xcode release. It only has 10.11 SDK. I?m planning to use a VM running > OS X 10.10 with the previous Xcode for public builds, which is not your problem. > > On windows I have seen issues with runtime API incompatibly between older > and newer compiler. At least on Windows you must use the right compiler and > runtime to match the python build you have. That is almost never aan issue on OS X although YMMV. The primary tricky part is using system provided versions of 3th party libraries. > > Linux is trouble free as python is built with the distribution?s chosen > compiler which is the one you use to build the extension. > >> Conversely, are there any upsides? Does a newer deployment target allow >> more recent compilers and/or higher optimizations? > > The upside is indeed better compiler and access to newer/fixed APIs. Not really. The deployment target tells the compiler the lowest OS X version you want to deploy to and doesn't affect which APIs you can use. APIs not available on older OSX versions can still be used, but are weak linked and that means C function pointers might be NULL. In a small number of cases the deployment target affects the function signature of UNIX APIs, but AFAIK that was only used with the introduction of 64bit on OSX and shouldn't affect code running on OS X 10.5 or later. Ronald > > Barry > >> >> -Andrew >> >> _______________________________________________ >> Pythonmac-SIG maillist - Pythonmac-SIG at python.org >> https://mail.python.org/mailman/listinfo/pythonmac-sig >> unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > https://mail.python.org/mailman/listinfo/pythonmac-sig > unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG From barry at barrys-emacs.org Tue Oct 27 08:59:32 2015 From: barry at barrys-emacs.org (Barry Scott) Date: Tue, 27 Oct 2015 12:59:32 +0000 Subject: [Pythonmac-SIG] OS X Python: can I explicitly set MACOSX_DEPLOYMENT_TARGET for extensions? In-Reply-To: <52D88A96-95C8-4406-A425-87DB8626F95A@mac.com> References: <09E0A982-89BF-402D-8253-186CE29CC941@barrys-emacs.org> <52D88A96-95C8-4406-A425-87DB8626F95A@mac.com> Message-ID: <2626062.UUN9Zp48ku@varric.chelsea.private> On Tuesday 27 October 2015 12:34:11 Ronald Oussoren wrote: > Op 27 okt. 2015 om 09:42 heeft Barry Scott het volgende geschreven: > >> On 19 Oct 2015, at 16:25, Andrew Jaffe wrote: > >> > >> [Also posted to general python list...] > >> > >> I use the python.org framework build of Python under recent versions of > >> OS X (i.e., 10.11 El Capitan). I need to build some extensions that rely > >> on recent versions of compilers (e.g., C++-11 features). However the > >> python.org python is built to work on older systems as well, for > >> backward compatibility. > >> > >> Hence, it has the environment variable MACOSX_DEPLOYMENT_TARGET=10.6. > >> This means that extensions are built by default with a toolchain that, I > >> think, mimics gcc-4.2, in particular in terms of what stdlib it searches. > >> > >> In the past, I have fixed this by installing more recent compilers with > >> homebrew and explicitly setting CC, CXX, etc before installation. > >> > >> However, I have tried just setting MACOSX_DEPLOYMENT_TARGET=10.11, and > >> that seems to work. Is this safe? Are there any downsides? (I don't need > >> to distribute these builds, just use them locally?) > > > > I built pysvn with MACOSX_DEPLOYMENT_TARGET being 10.9, 10.10 and 10.11 > > without issue. But I am not using c++11 features yet. > > > > I?m facing the problem that the SDK for 10.9 and 10.10 is missing from the > > latest Xcode release. It only has 10.11 SDK. I?m planning to use a VM > > running OS X 10.10 with the previous Xcode for public builds, which is > > not your problem. > > > > On windows I have seen issues with runtime API incompatibly between older > > and newer compiler. At least on Windows you must use the right compiler > > and > > runtime to match the python build you have. > > That is almost never aan issue on OS X although YMMV. The primary tricky > part is using system provided versions of 3th party libraries. What I neglected to say and your comments reminded me of is that I use the SDK for the matching target to avoid issues with missing API. That has helped with compat with openssl and sqlite for example. > > Linux is trouble free as python is built with the distribution?s chosen > > compiler which is the one you use to build the extension. > > > >> Conversely, are there any upsides? Does a newer deployment target allow > >> more recent compilers and/or higher optimizations? > > > > The upside is indeed better compiler and access to newer/fixed APIs. > > Not really. The deployment target tells the compiler the lowest OS X version > you want to deploy to and doesn't affect which APIs you can use. APIs not > available on older OSX versions can still be used, but are weak linked and > that means C function pointers might be NULL. Interesting I did not know that. > In a small number of cases the deployment target affects the function > signature of UNIX APIs, but AFAIK that was only used with the introduction > of 64bit on OSX and shouldn't affect code running on OS X 10.5 or later. Barry > > Ronald > > > Barry > > > >> -Andrew > >> > >> _______________________________________________ > >> Pythonmac-SIG maillist - Pythonmac-SIG at python.org > >> https://mail.python.org/mailman/listinfo/pythonmac-sig > >> unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG > > > > _______________________________________________ > > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > > https://mail.python.org/mailman/listinfo/pythonmac-sig > > unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG 1