Hacker News new | ask | show | jobs
by douglasheriot 3667 days ago
Picking files out of homebrew for distribution is generally a bad idea. You’ve fixed the linking issues, but not -mmacosx-version-min.

If you run $ otool -l libpython3.5.dylib and look for LC_VERSION_MIN_MACOSX – you’ll see it’s compiled only for your current OS.

So, if you do this on OS X 10.11, your users will have to have OS X 10.11. It may appear to work on older versions of OS X, until you hit something that doesn’t. For example, when I tried using a homebrew library, it was compiled using newer SSE instructions that weren’t supported on older processors still supported by older OS X versions. So when testing on an old Mac, it crashed with bad instruction at a somewhat random point in execution.

1 comments

Hum, nice catch! Maybe there is a way to change that LC_VERSION_MIN_MACOSX variable, although the compilation generated instructions may be a dead end.

I see two possible solutions, either try to work out from the Python provided binaries (which support OS X 10.6) or try to compile it from source in a way that is backwards compatible, Maybe cpython's makefile has some support for that?!..

I can confirm that the Python dynamic library installed from python.org do not have any reference to LC_VERSION_MIN_MACOSX. So in theory, it would work on any OS X version..

The only catch is that the official binaries are 32/64 bits which means that the shared library is 6MB instead of 2MB for the homebrew version, and the standard library zip is 23MB instead of 10MB for the homebrew's version..

I've updated the blog post with those remarks in the end.

If it's an autoconf project you should be able to (as far as I recall) pass appropriate min version and architecture flags to ./configure

Python bundles a bunch of modules one may not need for embedding in either case, and they can be turned into byte code before distribution.

I've managed to compile Python 3.5 from source setting MACOSX_DEPLOYMENT_TARGET=10.8 on the Makefile (after doing ./configure). But by default it compiles Python to a static library, which is quite ok, but I am having trouble compiling to a "Framework", which I think would give me the dynamic library.

Although Python is widely used, everything related to these kind of things seems to be poorly documented..

Edit: just need to do "./configure --enable-shared" and it will compile Python as shared library (libpython3.5m.dylib)..

I think I have set CFLAGS to something like "-arch x86_64 -mmacosx-version-min=10.8″ when running ./configure to autoconf projects.

It's not really specific to Python, so "poorly documented" isn't a surprise.

For Python you just need to do "./configure MACOSX_DEPLOYMENT_TARGET=10.8"..

I'm creating another blog post with all the info I got from this thread, regarding compiling Python from sources. I'm going to put the link here when ready..

Edit: http://joaoventura.net/blog/2016/embeddable-python-osx-from-...