OSX 32-bit Cython

95 views
Skip to first unread message

dbv

unread,
May 24, 2013, 9:29:31 AM5/24/13
to cython...@googlegroups.com
How would you build a 32-bit version of Cython on a 64-bit OSX machine?

Chris Barker - NOAA Federal

unread,
May 24, 2013, 1:01:42 PM5/24/13
to cython...@googlegroups.com
On Fri, May 24, 2013 at 6:29 AM, dbv <dinesh...@hotmail.com> wrote:
> How would you build a 32-bit version of Cython on a 64-bit OSX machine?

use a 32 bit Python.

Apple's python (I think) is universal, so with the right magic
incantations, you can get it to run in 32 bit mode. However, I've
found that trickly, particularly for building extensions.

My solution is a total hack:

1) Install one of the binaries from Python.org:

32 bit ppc_Intel
32+64 bit

whichone depends on if you want to support older systems, and if you
are OK with using an older complier.

2) Hack it to run the one you want:
- for the 32 bit one, if you're running an intel machine, it will
run 32bit intel -- you're done
- for the Intel one, you can use lipo to remove the 64 bit binary
from the main python executable (I told you this was a hack!)

3) hack the config so that it will only build the platform you want
when bulding extensions:
edit: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/Makefile

remove the "-arch x86_64" or "-arch ppc" from the two places it
appears in there.

then you'll have a 32 bit python that builds 32 bit only extensions.

yes -- this is a major hack, but it's working for me.

-Chris



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris....@noaa.gov

dbv

unread,
May 24, 2013, 2:04:20 PM5/24/13
to cython...@googlegroups.com
Hi Chris

Got it to work before receiving your response.  Force Python to run in 32-bit mode (for Intel only) with:

$ arch -i386 python

Used this to build 32-bit Cython from the tar ball (ie. $ arch -i386 python setup.py install).  Managed to build 32-bit extensions but gevent (1.0 beta), which is built using Cython, works in 64-bit Python but not in 32-bit.  Not sure why yet.

Chris Barker - NOAA Federal

unread,
May 24, 2013, 2:42:12 PM5/24/13
to cython...@googlegroups.com
On Fri, May 24, 2013 at 11:04 AM, dbv <dinesh...@hotmail.com> wrote:

> Got it to work before receiving your response. Force Python to run in
> 32-bit mode (for Intel only) with:
>
> $ arch -i386 python
>
> Used this to build 32-bit Cython from the tar ball (ie. $ arch -i386 python
> setup.py install).

yup -- that is what's supposed to work, but I find it gets confused
some times...

> Managed to build 32-bit extensions

by the way, without the flag you'd get a 32+64 bit universal Cython,
which would work fine with a 32 bit python...why do you need a 32 bit
only Cython?

> but gevent (1.0
> beta), which is built using Cython, works in 64-bit Python but not in
> 32-bit. Not sure why yet.

well, if no one's testing 32 bit, I'd expect some hick-ups!

you will need to be careful to pass on that arch flag whenever
running pyton for building, etc...

Robert Bradshaw

unread,
May 24, 2013, 2:59:23 PM5/24/13
to cython...@googlegroups.com
On Fri, May 24, 2013 at 11:42 AM, Chris Barker - NOAA Federal
<chris....@noaa.gov> wrote:
> On Fri, May 24, 2013 at 11:04 AM, dbv <dinesh...@hotmail.com> wrote:
>
>> Got it to work before receiving your response. Force Python to run in
>> 32-bit mode (for Intel only) with:
>>
>> $ arch -i386 python
>>
>> Used this to build 32-bit Cython from the tar ball (ie. $ arch -i386 python
>> setup.py install).
>
> yup -- that is what's supposed to work, but I find it gets confused
> some times...
>
>> Managed to build 32-bit extensions
>
> by the way, without the flag you'd get a 32+64 bit universal Cython,
> which would work fine with a 32 bit python...why do you need a 32 bit
> only Cython?
>
>> but gevent (1.0
>> beta), which is built using Cython, works in 64-bit Python but not in
>> 32-bit. Not sure why yet.
>
> well, if no one's testing 32 bit, I'd expect some hick-ups!

We do test 32-bit on linux, but don't have a OS X build bot (though
it's a common development platform).

https://sage.math.washington.edu:8091/hudson/job/cython-devel-tests/

> you will need to be careful to pass on that arch flag whenever
> running pyton for building, etc...

Yep.

- Robert

dbv

unread,
May 24, 2013, 3:16:31 PM5/24/13
to cython...@googlegroups.com
The $ arch -i386 flag is easy to forget but batch automated builds makes it easier.

Need 32-bit Cython for portfolio of 32-bit products but coming to the conclusion that for OSX, 64-bit is the only way to go.

Reply all
Reply to author
Forward
0 new messages